/**
 * 定义命名空间 
 */
Ext.ns("divo.admin.test")
Ext.ns("divo.admin.portal")
Ext.ns("divo.admin.user")
Ext.ns("divo.admin.group")
Ext.ns("divo.admin.menu")

Ext.ns("divo.xf.producer")
Ext.ns("divo.xf.projecter")
Ext.ns("divo.xf.checker")
Ext.ns("divo.xf.product")
Ext.ns("divo.xf.newproduct")
Ext.ns("divo.xf.queryproduct")
Ext.ns("divo.xf.checkreport")
Ext.ns("divo.xf.corpuser")
Ext.ns("divo.xf.mainter")
Ext.ns("divo.xf.advisor")
Ext.ns("divo.xf.auditproduct")
Ext.ns("divo.xf.querycheckreport")
//EOP
;/**
 * 编写检测报告
 */
divo.xf.checkreport.MainPanel = Ext.extend(divo.panel.PanelWithHtmlBtns, {
	initComponent : function() {
		if (!this.isCheckerUser()) {
			alert("对不起，非消防系统检测单位会员用户不能使用此功能。")
			divo.xf.checkreport.MainPanel.superclass.initComponent.call(this)
			return
		}
		var corpInfo = this.getCorpInfo()
		this.checkReportPermission = this.getCheckReportPermission()
		
		this.checkReportGridPanelId = this.myId('checkreport')
		this.checkReportActionPanelId = this.myId('action')

		Ext.apply(this, {
			layout : 'tdgi_border',
			defaults : {
				border : false
			},
			border : false,
			items : [{
				region : 'center',
				layout : 'fit',
				autoScroll : true,
				title : '需要继续完善的检测报告列表: ' + corpInfo.name + ' - '
						+ this.getUserFullName(),
				ctCls : "j-toolbar-dark",
				items : [this.getCenterContent()]
			}, {
				stateful : true,
				stateId : this.myId('action'),
				title : '检测报告内容',
				region : 'east',
				collapsible : false,
				ctCls : "j-toolbar-dark",
				width : 380,
				collapsedTitle : true,
				split : true,
				layout : 'fit',
				items : [{
					id : this.checkReportActionPanelId,
					xtype : "panel.xf.CheckReportActionPanel",
					checkReportPermission : this.checkReportPermission
				}],
				plugins: new Ext.ux.plugins.HeaderButtons(),
				hbuttons: [{
						text: '添加系统',
						handler : this.addSystem,
						icon : divo.iconAdd,
						cls : 'x-btn-text-icon',
						scope : this,
						hidden : !this.checkReportPermission.canWrite
					}]
			}]
		})

		this.subscribe("divo.rowSelect" + this.checkReportGridPanelId,
				this.onCheckReportChange, this)
		this.subscribe("window.xf.CheckReportSystemAdded",
				this.onSystemAdded, this)
				
		this.on('beforedestroy', function() {
			this.unsubscribe()
		}, this)

		divo.xf.checkreport.MainPanel.superclass.initComponent.call(this)
	},
	onCheckReportChange : function(subj, msg, data) {
		this.checkReport = null
		if (msg.id && msg.record)
	    	this.checkReport = msg.record.data
		Ext.getCmp(this.checkReportActionPanelId).setCurrentCheckReport(msg)
	},
	getCenterContent : function() {
		return new Ext.Panel({
			layout : 'border',
			defaults : {
				border : false
			},
			border : false,
			items : [{
				region : 'center',
				layout : 'fit',
				autoScroll : true,
				items : [{
					id : this.checkReportGridPanelId,
					xtype : "panel.xf.CheckReportGridPanel",
					menuItemId : this.menuItemId,
					checkerId : corpInfo.id,
					checkReportPermission : this.checkReportPermission
				}]
			}, this.getHtmlBtnsPanel({
					'new' : {
						image : 'checkreport-new.png',
						fn : this.addNewCheckReport,
						hidden : !this.checkReportPermission.canWrite
					},
					'print' : {
						image : 'print_view.png',
						fn : this.printCheckReport
					},
					'over' : {
						image : 'checkreport-over.png',
						fn : this.publishCheckReport,
						hidden : !this.checkReportPermission.canPublish
					}
				})]
		})
	},
	addNewCheckReport : function() {
		Ext.getCmp(this.checkReportGridPanelId).addItem()
	},
	publishCheckReport : function() {
		Ext.getCmp(this.checkReportGridPanelId).publishReport()
	},
	printCheckReport : function() {
		Ext.getCmp(this.checkReportGridPanelId).printReport()
	},
	getCheckReportPermission : function(corpInfo) {
		if (!this.isSecondaryCorpUser()) {
			return {canWrite:true,  //能否填写检测报告
					 canPublish:true} //能否确认报告已完成
		}
		var p = {}
		Ext.Ajax.request({
			scope : this,
			url : "/xf/checkusers/users/"+this.getUserId()+"/permissions",
			async : false,
			method : 'GET',
			success : function(response, options) {
				var resp = Ext.decode(response.responseText)
				p = {canWrite:resp.data.p2,
					 canPublish:resp.data.p3}
			}
		})
		return p
	},
	addSystem : function() {
		if (!this.checkReport || !this.checkReport.active) {
		    this.say("请先选择正在填写的检测报告")	
		    return
		}
		if (this.checkReport.report_type==2) {
		    this.say("“钢结构防火喷涂施工质量检测报告”不能添加新系统")	
		    return
		}
		var win = new window.xf.CheckReportSystemAddWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReport.id,
			checkReportType : this.checkReport.report_type
		})
		win.show()
	},
	onSystemAdded : function(subj, msg, data) {
		Ext.getCmp(this.checkReportActionPanelId).showActions()
	}
})

divo.xf.checkreport.Main = function() {
	/* ----------------------- private变量 ----------------------- */

	/* ----------------------- private方法 ----------------------- */
	// 创建布局
	function createLayout(parentPanel, menuItemId) {
		parentPanel.add(new divo.xf.checkreport.MainPanel({
			id : 'xf-checkreport',
			menuItemId : menuItemId
		}))
		parentPanel.doLayout()
	}

	/* ----------------------- public方法 ----------------------- */
	return {

		// 初始化
		init : function(parentPanel, menuItemId) {
			createLayout(parentPanel, menuItemId)
		}

	} // return

}()
// EOP

;/**
 * 定义命名空间 
 */
Ext.ns("divo.panel")

Ext.ns("form.test")
Ext.ns("panel.test")
Ext.ns("window.test")
Ext.ns("grid.test")
Ext.ns("tree.test")
Ext.ns("data.test")

Ext.ns("panel.admin")
Ext.ns("form.admin")
Ext.ns("window.admin")
Ext.ns("tree.admin")
Ext.ns("grid.admin")

Ext.ns("panel.xf")
Ext.ns("form.xf")
Ext.ns("window.xf")
Ext.ns("grid.xf")

//EOP
;/**
 * 正在编写的检测报告网格面板
 */
panel.xf.CheckReportGridPanel = Ext.extend(divo.panel.SmartGridDetailPanel, {
	checkerId : null,
	checkReportPermission : null,
	initComponent : function() {
 		this.action = new Ext.ux.grid.RowActions({
            header:'操作',
            autoWidth:false, 
            width:60,
            actions:[{
                iconCls:'icon-delete',
                tooltip:'删除检测报告',
				hideIndex : 'can_delete'
            }]
        })
		this.action.on('action',this.onAction,this)
	
		Ext.apply(this, {
			url : "/xf/checkreports/unclosed/users/"+this.getUserId(),
			fieldDefinitions : this.getListDefinitions(),
			gridConfig : {
				gridIdOfView : 'xf-check-report-grid', 
				filter : false,
				plugins : this.checkReportPermission.canWrite?[this.action]:undefined,
				displayLoadMask : false
			},
			autoScroll : true
		})
		
		this.subscribe("window.xf.CheckReportChanged",this.onCheckReportChanged,this)
		this.on('beforedestroy',function() {
		      this.unsubscribe()
		},this)
		
		panel.xf.CheckReportGridPanel.superclass.initComponent.apply(this,arguments)
	},
	onAction : function(grid, record, action, row, col) {
		if (action=='icon-delete')
		    this.deleteItem()
	},
	//重写
	createGridMeta : function() {
		return this.getGridMeta(this.fieldDefinitions,this.checkReportPermission.canWrite?[this.action]:undefined)
	},
	//重写
	onGridLoad : function(store, records, options) {
		if (this.ds.getTotalCount() == 0 || !this.cId) {
			this.cId = null
			this.cName = null
			this.notifyRowChange()
		} //取消自动选中功能, 发布或删除后能使右侧面板内容消失
	},
	getListDefinitions : function() {
		return [{
			name : 'id'
		},{
			name : 'report_type'
		},{
			name : 'tryout_only',
			type : 'bool'
		},{
			name : 'check_type_name'
		},{
			header: "序号", 
			width: 30, 
			renderer: this.rowNumberRender.createDelegate(this)			
		},{
			name : 'project_name',
			header : '工程名称',
			type : 'string',
			renderer: this.wordWrapRender.createDelegate(this)
		},{
			name : 'code',
			header : '报告文号',
			type : 'string'
		},{
			name : 'added_on',
			header : '录入日期',
			renderer: this.addedOnRender.createDelegate(this),		
			type : 'string'
		},{
			name : 'approve_by',
			header : '批准人',
			type : 'string'
		},{
			name : 'audit_by',
			header : '审核人',
			type : 'string'
		},{
			name : 'check_by',
			header : '现场检测负责人',
			type : 'string'
		}, {
			name : 'active',
			header : '状态',
			type : 'bool',
			renderer : this.activeRender.createDelegate(this)
		}, {
			name : 'can_delete',
			type : 'bool',
			convert : function(v, rec) {
				return !rec.active
			}
		}]
	},
	activeRender : function(value, p, record) {
		return (value ? '正在填写' : '已删除')
	},
	//public
	printReport : function() {
		if (!this.cId) {
			this.say("请先选择一份检测报告")
			return
		}
		var win = new window.xf.CheckReportPDFWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.cId
		})
		win.show()
	},
	//public
	publishReport : function() {
		if (!this.cId) {
			this.say("请先选择一份检测报告")
			return
		}
		var record = this.selModel.getSelections()[0]
		if (!record.data.active) {
			this.say("此检测报告已删除")
			return
		}
		Ext.MessageBox.confirm("确认", "如按“是”按钮则会生成完整的检测报告，不可自行修改、删除。如有改动需与消防产业委员会联系！", 
								this.publishReportConfirm.createDelegate(this))
	},
	publishReportConfirm : function(btn) {
		if (btn != "yes") 
			return
		this.sayWait("处理，请稍候")	
		Ext.getBody().mask('','x-mask-loading')
		Ext.Ajax.request({
			scope : this,
			url : "/xf/checkreports/"+this.cId+"/validateresults/count",
			async : true,
			method : 'GET',
			success : function(response, options) {
				var resp = Ext.decode(response.responseText)
				if (resp.validateResultCount==0) {
					this.publishReportDone()
				} else {
					this.sayClear()
					Ext.getBody().unmask()
					this.showValidateResults()
				}
			},
			failure : function(response, options) {
				this.sayClear()
				Ext.getBody().unmask()
				this.alert(response.responseText)
			}
		})
	},	
	publishReportDone : function() {		
		Ext.Ajax.request({
			scope : this,
			async : true,
			url : '/xf/checkreports/'+this.cId+'/status/publish',
			method : 'GET',
			success : function(response, options) {
				this.sayClear()
				Ext.getBody().unmask()
				var resp = Ext.decode(response.responseText)
				if (resp.success) {
					this.say("确认报告已完成操作成功")
	    			this.cId = null  //让右边Panel内容消失
					this.loadList()
				} else {
				    alert('操作失败，请再试一次，或与系统管理员联系。')
				}
			},
			failure : function(response) {
				this.sayClear()
				Ext.getBody().unmask()
				this.alert(response.responseText);
			}
		})
	},
	showValidateResults : function() {
		var win = new window.xf.CheckReportValidateResultWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.cId,
			checkReportCode : this.cRecordData.code
		})
		win.show()
	},
	//public
	addItem : function() {
		this.checkreportWindowId = this.myId('win')
		
		var win = new window.xf.CheckReportAddOrEditWindow({
			id : this.checkreportWindowId,
			closeAction : "destroy",
			cancelAction : "destroy",
			adding : true,
			checkerId : this.checkerId
		})
		win.show()
	},
	onCheckReportChanged : function(subj, msg, data) {
		this.cIdFocus = msg.id
		this.loadList()
	},
	onDeleteItem : function(id) {
		Ext.Ajax.request({
			scope : this,
			url : "/xf/checkreports/"+id+"/status",
			method : 'GET',
			success : function(response, options) {
				var resp = Ext.decode(response.responseText)
				if (resp.success) {
					this.cId = null  //让右边Panel内容消失
					this.loadList()
				} else {
				    this.say(resp.errors.reason)
				}
			},
			failure : function(response, options) {
				this.alert(response.responseText)
			}
		})
	}

})

Ext.reg('panel.xf.CheckReportGridPanel', panel.xf.CheckReportGridPanel);
// EOP

;/**
 * 检测报告内容操作列表面板
 * 
 * --------------------------------------------------------------
 * 消息：
 * 检测报告内容修改了
 * 
 * 消息名：     			
 * window.xf.CheckReportChanged    
 * 
 * 消息内容：
 * {int} sender 本组件的id值
 * {int} id 当前检测报告记录Id
 * --------------------------------------------------------------
 */
panel.xf.CheckReportActionPanel = Ext.extend(Ext.Panel, {
	readOnly : false,
	checkReportPermission : null,
	systemWindowWidth : 900, //统一各系统内容输入窗口宽度
	initComponent : function() {
		this.actionListId = this.myId("action-list")
		this.actionPanelId = this.myId('action-panel')
		this.actionIdOfMaster = this.myId("master")
		this.actionIdOfProducts = this.myId("products")
		
		this.realReadOnly = this.readOnly
		
		Ext.apply(this, {
			autoScroll : true,
			items : [{
				id : this.actionPanelId,
				xtype : "clickactionpanel",
				bodyStyle : 'padding: 10px;',
				html : '<ul id="'+this.actionListId+'" class="check_type_list"></ul>'
			}]
		})
		
		this.subscribe("ux.clickAction",this.onClickAction,this)
		
		this.subscribe("window.xf.CheckReportContentChanged",this.onRefreshActions,this)
		this.on('beforedestroy',function() {
		      this.unsubscribe()
		},this)

		panel.xf.CheckReportActionPanel.superclass.initComponent.apply(this,arguments)
	},
	//public
	setCurrentCheckReport : function(msg) {
		if (msg.id && msg.record)
	    	this.checkReport = msg.record.data
	    else
	        this.checkReport = null
	    if ((this.checkReportPermission && !this.checkReportPermission.canWrite) || 
	        (this.checkReport && !this.checkReport.active))    
	    	this.readOnly = true  
	    else
	        this.readOnly = this.realReadOnly
	    this.showActions()
	},
	onRefreshActions : function() {
		this.publish("window.xf.CheckReportChanged",{
			sender:this.id,
			id : this.checkReport.id
		})
	    this.showActions()
	},
	//public
	showActions : function() {
		var el = Ext.get(this.actionListId)
		
		if (!this.checkReport) {
			el.dom.innerHTML = '(请选择一份检测报告)'
			return
		}
		
		var html = []
		html.push('<div class="page-title">'+this.checkReport.project_name+'</div>')
		
		//总表
		html.push('\
        <li> \
          <img align="absmiddle" src="'+ divo.iconUrl+ 'icon32/li_master.png"/> \
          <a id="'+this.actionIdOfMaster+'" href="#">检测报告总表</a>'+(this.readOnly?"":this.getStateOfMaster())+' \
        </li> ')
          
        var systems = this.getSystems()
        var status,systemName,sysId,imageUrl,delLink
        for (var i = 0; i < systems.length; i++) {
        	status = ''
        	if (systems[i].updated_on)
       		    status = '<span class="common-text">填写时间:'+systems[i].updated_on+'</span>'
       		    
            systemName = systems[i].system_name+(systems[i].name?"-"+systems[i].name:"")
            sysId = this.myId("-"+systems[i].system_code+"-"+systems[i].id+"-sys")
            delId = this.myId("-"+systems[i].system_code+"-"+systems[i].id+"-del")
            imageUrl = divo.iconUrl+ 'icon32/li_'+systems[i].system_code+'.png'
            delLink = ''
            if (this.checkReport.report_type==1)
       			delLink = '&nbsp;&nbsp;<a id="'+delId+'" href="#">'+
       		    	      '<img title="删除此系统" style="width:16px;height:16px" src="'+ divo.iconUrl+'divo/delete.png"/></a>'

       		var msg = '' 
            if (!this.readOnly) {
                if (status)
                    msg = "<li>"+status+delLink+"</li>"
                else    
                    msg = delLink
            }
            
			html.push('\
	        <li> \
	          <img align="absmiddle" src="'+ imageUrl+'"/> \
	          <a id="'+sysId+'" href="#">'+ systemName + '</a>'+ msg +' \
	        </li> ')
        }
        	
        //产品清单	
        html.push('\
        <li> \
          <img align="absmiddle" src="'+ divo.iconUrl+ 'icon32/li_product.png"/> \
          <a id="'+this.actionIdOfProducts+'" href="#">查看工程所用产品清单</a><br /> \
        </li>')
		
		el.dom.innerHTML = html.join('')
	},
	getStateOfMaster : function() {
		var status = ''
		Ext.Ajax.request({
			scope : this,
			url : "/xf/checkreports/"+this.checkReport.id+"/master/updatelog",
			async : false,
			method : 'GET',
			success : function(response, options) {
				var resp = Ext.decode(response.responseText)
				if (resp.updatedOn.length>0) {
					status = "填写时间:"+resp.updatedOn
				}
			},
			failure : function(response, options) {
				this.alert(response.responseText)
			}
		})
		return status?'<li><span class="common-text">'+status+'</span></li>':''
	},
	getSystems : function() {
		var systems = []
		Ext.Ajax.request({
			scope : this,
			url : "/xf/checkreports/"+this.checkReport.id+"/system",
			async : false,
			method : 'GET',
			success : function(response, options) {
				systems = Ext.decode(response.responseText)
			},
			failure : function(response, options) {
				this.alert(response.responseText)
			}
		})
		return systems
	},
	onClickAction : function(subj, msg, data) {
		if (msg.sender==this.actionPanelId) {
			var id = msg.targetId
			if (id==this.actionIdOfMaster) {
				this.showMaster()
				return
			}
			if (id==this.actionIdOfProducts) {
				this.showProducts()
				return
			}
			var ids = id.split('-')
			var systemCode = ids[ids.length-3]
			var systemId = ids[ids.length-2]
			if (ids[ids.length-1]=='sys')
				var cmd = 'this.showSystem'+systemCode+'('+systemId+')'
			else
				var cmd = 'this.deleteSystem('+systemId+')'
			eval(cmd)
		}
	},
	showMaster : function(subj, msg, data) {
		var win = new window.xf.CheckReportMasterWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReport.id,
			checkReportCode : this.checkReport.code,
			checkReportType : this.checkReport.report_type,
			readOnly : this.readOnly
		})
		win.show()
	},
	showSystem101 : function(systemId) {
		var win = new window.xf.CheckReportWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReport.id,
			checkReportCode : this.checkReport.code,
			checkReport : this.checkReport,
			readOnly : this.readOnly,
			sysName : '火灾自动报警系统', 
			systemCode : '101',
			systemId : systemId,
			customWidth : this.systemWindowWidth,
			sysPanelXtype : 'panel.xf.CheckReport101Panel'
		})
		win.show()
	},
	showSystem102 : function(systemId) {
		var win = new window.xf.CheckReportWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReport.id,
			checkReportCode : this.checkReport.code,
			checkReport : this.checkReport,
			readOnly : this.readOnly,
			sysName : '机械防排烟系统', 
			systemCode : '102',
			systemId : systemId,
			customWidth : this.systemWindowWidth,
			sysPanelXtype : 'panel.xf.CheckReport102Panel'
		})
		win.show()
	},
	showSystem103 : function(systemId) {
		var win = new window.xf.CheckReportWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReport.id,
			checkReportCode : this.checkReport.code,
			checkReport : this.checkReport,
			readOnly : this.readOnly,
			sysName : '泡沫灭火系统', 
			systemCode : '103',
			systemId : systemId,
			customWidth : this.systemWindowWidth,
			sysPanelXtype : 'panel.xf.CheckReport103Panel'
		})
		win.show()
	},
	showSystem104 : function(systemId) {
		var win = new window.xf.CheckReportWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReport.id,
			checkReportCode : this.checkReport.code,
			checkReport : this.checkReport,
			readOnly : this.readOnly,
			sysName : '气体灭火系统', 
			systemCode : '104',
			systemId : systemId,
			customWidth : this.systemWindowWidth,
			sysPanelXtype : 'panel.xf.CheckReport104Panel'
		})
		win.show()
	},
	showSystem105 : function(systemId) {
		var win = new window.xf.CheckReportWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReport.id,
			checkReportCode : this.checkReport.code,
			checkReport : this.checkReport,
			readOnly : this.readOnly,
			sysName : '室内外消火栓给水系统', 
			systemCode : '105',
			systemId : systemId,
			customWidth : this.systemWindowWidth,
			sysPanelXtype : 'panel.xf.CheckReport105Panel'
		})
		win.show()
	},
	showSystem106 : function(systemId) {
		var win = new window.xf.CheckReportWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReport.id,
			checkReportCode : this.checkReport.code,
			checkReport : this.checkReport,
			readOnly : this.readOnly,
			sysName : '自动喷水灭火系统', 
			systemCode : '106',
			customWidth : this.systemWindowWidth,
			systemId : systemId,
			sysPanelXtype : 'panel.xf.CheckReport106Panel'
		})
		win.show()
	},
	showSystem107 : function(systemId) {
		var win = new window.xf.CheckReportWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReport.id,
			checkReportCode : this.checkReport.code,
			checkReport : this.checkReport,
			readOnly : this.readOnly,
			sysName : '细水雾灭火系统', 
			systemCode : '107',
			systemId : systemId,
			customWidth : this.systemWindowWidth,
			sysPanelXtype : 'panel.xf.CheckReport107Panel'
		})
		win.show()
	},
	showSystem201 : function(systemId) {
		var win = new window.xf.CheckReportWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReport.id,
			checkReportCode : this.checkReport.code,
			checkReport : this.checkReport,
			readOnly : this.readOnly,
			sysName : '钢结构防火喷涂施工质量检测记录表', 
			systemCode : '201',
			customWidth : this.systemWindowWidth,
			systemId : systemId,
			sysPanelXtype : 'panel.xf.CheckReport201Panel'
		})
		win.show()
	},
	showProducts : function(subj,msg,data) {
		var win = new window.xf.CheckReportAllProductWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReport.id
		})
		win.show()
	},
	deleteSystem : function(systemId) {
		this.systemId = systemId
		Ext.MessageBox.confirm('确认', '要删除此系统吗？', 
			this.onDeleteSystemConfirm.createDelegate(this))
	},	
	onDeleteSystemConfirm : function(btn) {
		if (btn !== 'yes')
		    return
			    
		var ok = true
		Ext.Ajax.request({
			scope : this,
			url : "/xf/checkreports/"+this.checkReport.id+"/system/"+this.systemId,
			async : false,
			method : 'DELETE',
			failure : function(response, options) {
				this.alert(response.responseText)
				ok = false
			}
		})
		if (ok)
		    this.showActions()
	}
})

Ext.reg('panel.xf.CheckReportActionPanel', panel.xf.CheckReportActionPanel)
// EOP

;/**
 * 工程施工单位网格面板
 */
panel.xf.ProjecterGridPanel = Ext.extend(divo.panel.SmartGridDetailPanel, {
	initComponent : function() {
 		this.action = new Ext.ux.grid.RowActions({
            header:'操作',
            autoWidth:false, 
            width:60,
            actions:[{
                iconCls:'icon-update',
                tooltip:'修改工程施工单位',
                hide : !this.canUpdate()
            },{
                iconCls:'icon-delete',
                tooltip:'删除工程施工单位',
                hide : !this.canDelete()
            }]
        })
		this.action.on('action',this.onAction,this)
	
		Ext.apply(this, {
			url : "/xf/projecters",
			fieldDefinitions : this.getListDefinitions(),
			gridConfig : {
				gridIdOfView : 'xf-projecter-grid', 
				filter : true,
				toolbar : this.isLookup?false:this.createToolbarBtn(),
				plugins : [this.action],
				autoExpandColumn : 'name'
			},
			autoScroll : true
		})
		
		this.subscribe("window.xf.ProjecterChanged", this.onProjecterChanged, this)
		this.on('beforedestroy', function() {
			this.unsubscribe()
		}, this)
		
		panel.xf.ProjecterGridPanel.superclass.initComponent.apply(this,arguments)
	},
	onAction : function(grid, record, action, row, col) {
		if (action=='icon-update')
		    this.editItem()
		if (action=='icon-delete')
		    this.deleteItem()
	},
	//重写
	createGridMeta : function() {
		return this.getGridMeta(this.fieldDefinitions,this.isLookup?null:[this.action])
	},
	getListDefinitions : function() {
		return [{
			name : 'id'
		},{
			name : 'project_grade'
		},{
			name : 'name',
			header : '企业名称',
			searchable : true,
			type : 'string',
			id : 'name'
		},{
			name : 'py',
			header : '拼音助记符',
			searchable : true,
			type : 'string'
		},{
			name : 'area_name',
			header : '地区',
			type : 'string'
		}]
	},
	createToolbarBtn : function(){
		var tb = [];

		var addBtn = new Ext.Toolbar.Button( {
			text : '新建',
			tooltip : '新建工程施工单位',
			icon : divo.iconAdd,
			cls : 'x-btn-text-icon',
			hidden : !this.canCreate(),
			handler : this.addItem.createDelegate(this)
		})
		tb.push(addBtn)
		return tb
	},
	addItem : function() {
		this.projecterWindowId = this.myId('win')

		var win = new window.xf.ProjecterAddOrEditWindow({
			id : this.projecterWindowId,
			closeAction : "destroy",
			cancelAction : "destroy",
			adding : true
		})
		win.show()
	},
	editItem : function() {
		if (!this.cId) {
			this.say("请先选择要修改的记录")
			return
		}
		this.projecterWindowId = this.myId('win')

		var win = new window.xf.ProjecterAddOrEditWindow({
			id : this.projecterWindowId,
			closeAction : "destroy",
			cancelAction : "destroy",
			adding : false,
			projecterId : this.cId
		})
		win.show()
	},
	onProjecterChanged : function(subj, msg, data) {
		if (msg.sender == this.projecterWindowId) {
			this.cIdFocus = msg.id
			this.loadList()
		}
	},
	onLoadItem : function(id) {
		Ext.Ajax.request({
			scope : this,
			url : this.url+'/'+id,
			method : 'GET',
			success : function(response, options) {
				var resp = Ext.decode(response.responseText);
				this.fillForm(resp.data)
			},
			failure : function(response, options) {
				this.alert(response.responseText);
			}
		})
	},
	onDeleteItem : function(id) {
		Ext.Ajax.request({
			scope : this,
			url : this.url+'/'+id,
			method : 'DELETE',
			success : function(response, options) {
				var resp = Ext.decode(response.responseText)
				if (resp.success)
					this.deleteItemCallback()
				else
				    this.sayError(resp.errors.reason) 
			},
			failure : function(response, options) {
				this.alert(response.responseText)
			}
		})
	}

})

Ext.reg('panel.xf.ProjecterGridPanel', panel.xf.ProjecterGridPanel);
// EOP

;/**
 * 消防产品网格面板
 */
panel.xf.ProductGridPanel = Ext.extend(divo.panel.SmartGridDetailPanel, {
	initComponent : function() {
		this.action = new Ext.ux.grid.RowActions({
			header : '操作',
			autoWidth : false,
			width : 60,
			actions : [{
				iconCls : 'icon-update',
				tooltip : '修改消防产品',
				hide : !this.canUpdate()
			}, {
				iconCls : 'icon-delete',
				tooltip : '删除消防产品',
				hide : !this.canDelete()
			}]
		})
		this.action.on('action', this.onAction, this)

		Ext.apply(this, {
			url : "/xf/products",
			fieldDefinitions : this.getListDefinitions(),
			gridConfig : {
				gridIdOfView : 'xf-product-grid',
				filter : true,
				toolbar : this.isLookup ? false : this.createToolbarBtn(),
				plugins : [this.action],
				autoExpandColumn : 'name'
			},
			autoScroll : true
		})

		this.subscribe("window.xf.ProductChanged", this.onProductChanged, this)
		this.on('beforedestroy', function() {
			this.unsubscribe()
		}, this)

		panel.xf.ProductGridPanel.superclass.initComponent.apply(this,
				arguments)
	},
	onAction : function(grid, record, action, row, col) {
		if (action == 'icon-update')
			this.editItem()
		if (action == 'icon-delete')
			this.deleteItem()
	},
	// 重写
	createGridMeta : function() {
		return this.getGridMeta(this.fieldDefinitions,this.isLookup?null:[this.action])
	},
	getListDefinitions : function() {
		return [{
			name : 'id'
		}, {
			name : 'name',
			header : '名称',
			searchable : true,
			type : 'string',
			id : 'name'
		}, {
			name : 'spec',
			header : '型号',
			type : 'string'
		},{
			name : 'py',
			header : '拼音助记符',
			searchable : true,
			type : 'string'
		}, {
			name : 'producer_name',
			header : '生产厂家',
			type : 'string',
			sortable : false,
			id : 'producer_name'
		}]
	},
	// 添加工具条按钮
	createToolbarBtn : function() {
		var tb = [];

		var addBtn = new Ext.Toolbar.Button({
			text : '新建',
			tooltip : '新建消防产品',
			icon : divo.iconAdd,
			cls : 'x-btn-text-icon',
			hidden : !this.canCreate(),
			handler : this.addItem.createDelegate(this)
		})
		tb.push(addBtn)
		return tb
	},
	addItem : function() {
		this.productWindowId = this.myId('win')

		var win = new window.xf.ProductAddOrEditWindow({
			id : this.productWindowId,
			closeAction : "destroy",
			cancelAction : "destroy",
			adding : true,
			productStatus : 2
		})
		win.show()
	},
	editItem : function() {
		if (!this.cId) {
			this.say("请先选择要修改的记录")
			return
		}
		this.productWindowId = this.myId('win')

		var win = new window.xf.ProductAddOrEditWindow({
			id : this.productWindowId,
			closeAction : "destroy",
			cancelAction : "destroy",
			adding : false,
			productId : this.cId
		})
		win.show()
	},
	onProductChanged : function(subj, msg, data) {
		if (msg.sender == this.productWindowId) {
			this.cIdFocus = msg.id
			this.loadList()
		}
	},
	onDeleteItem : function(id) {
		Ext.Ajax.request({
			scope : this,
			url : this.url + '/' + id,
			method : 'DELETE',
			success : function(response, options) {
				var resp = Ext.decode(response.responseText)
				if (resp.success)
					this.deleteItemCallback()
				else
					this.say(resp.errors.reason)
			},
			failure : function(response, options) {
				this.alert(response.responseText)
			}
		})
	}

})

Ext.reg('panel.xf.ProductGridPanel', panel.xf.ProductGridPanel);
// EOP

;/**
 * 评论网格面板
 */
panel.xf.CheckReportValidateResultGridPanel = Ext.extend(divo.panel.SmartGridPanel, {
	checkReportId : null,
	initComponent : function() {
		Ext.apply(this, {
			fieldDefinitions : this.getListDefinitions(),
			url : " /xf/checkreports/"+this.checkReportId+"/validateresults",
			gridConfig : {
				gridIdOfView : 'xf-check-report-validate-result-grid',
				footer : false,
				hideHeaders : true,
				autoExpandColumn : 'descrip'
			},
			autoScroll : true
		})
		
		panel.xf.CheckReportValidateResultGridPanel.superclass.initComponent.apply(this,arguments)
	},
	getListDefinitions : function() {
		return [{
			name : 'id'
		},{
			name : 'name'
		},{
			name : 'descrip',
			header : '描述',
			type : 'string',
			renderer : this.descripRender.createDelegate(this),
			id : 'descrip'
		}]
	},
	descripRender : function(value, p, record) {
		return String.format('<b>{0}</b> <div class="font-size:11pt">{1}</div>',
				record.data['name'],value.replace(/\n/g, "<br />"))
	}
})

Ext.reg('panel.xf.CheckReportValidateResultGridPanel', panel.xf.CheckReportValidateResultGridPanel);
// EOP

;/**
 * 检测报告中使用的消防产品清单网格面板
 */
panel.xf.CheckReportAllProductGridPanel = Ext.extend(divo.panel.SmartGridPanel, {
	checkReportId : null,
	initComponent : function() {
		Ext.apply(this, {
			fieldDefinitions : this.getListDefinitions(),
			url : '/xf/checkreports/'+this.checkReportId+'/products',
			gridConfig : {
				gridIdOfView : 'xf-check-report-products-grid',
				footerSimple : true,
				displayLoadMask : true
			},
			autoScroll : true
		})
		
		panel.xf.CheckReportAllProductGridPanel.superclass.initComponent.apply(this,arguments)
	},
	getListDefinitions : function() {
		return [{
			name : 'id'
		},{
			name : 'product_name',
			header : '产品名称',
			renderer: this.wordWrapRender.createDelegate(this),
			type : 'string'
		},{
			name : 'product_spec',
			header : '产品型号',
			renderer: this.wordWrapRender.createDelegate(this),
			type : 'string'
		},{
			name : 'amount',
			header : '数量',
			type : 'string'
		},{
			name : 'producer_name',
			header : '生产厂家',
			renderer: this.wordWrapRender.createDelegate(this),
			type : 'string'
		}]
	}
})

Ext.reg('panel.xf.CheckReportAllProductGridPanel', panel.xf.CheckReportAllProductGridPanel);
// EOP

;/**
 * 各系统输入面板
 */
panel.xf.CheckReportBasePanel = Ext.extend(Ext.TabPanel, {
	checkReportId : null,
	systemId : null,
	readOnly : false,
	checkReport : null,
	initComponent : function() {
		Ext.apply(this, {
			defaults : {
				bodyStyle : "padding:10px"
			},
			activeTab : 0,
			minTabWidth : 115,
			tabWidth : 135,
			enableTabScroll : true,
			items : this.getCheckReportItems()
		})
		panel.xf.CheckReportBasePanel.superclass.initComponent.call(this)
	},
	//子类需要重写
	getCheckReportItems : function() {
		return []
	},
	// public
	save : function(items) {
		if (!items)
			var items = this.items.items
		for (var i = 0; i < items.length; i++) {
			var obj = items[i]
			if (obj.rendered && obj.save)
				obj.save(true)
		}
	}
})
// EOP

;/**
 * 检测结果和说明输入网格
 */
panel.xf.CheckReportResultGridPanel  = Ext.extend(divo.panel.SmartGridPanel, {
	checkReportId : null,
	checkReport : null,
	systemId : null,	
	readOnly : null,
	systemCode : null,
	initComponent : function() {
		Ext.apply(this, {
			fieldDefinitions : this.getListDefinitions(),
			url : '/xf/checkreports/'+this.checkReportId+'/system/'+this.systemId+"/results",
			gridConfig : {
				gridIdOfView : 'xf-check-report-result-grid',
				footer : false,
				filter : false,
				cls : 'vline-on',
				toolbar : this.checkReport.report_type==2?undefined:this.createToolbarBtn(),
				displayLoadMask : true,
				groupField : 'content_item_name',
				groupSortInfo : {field: 'code', direction: "ASC"},
				editorGrid : true,
				allowGridState : false //程序中指定列宽
			},
			autoScroll : true
		})
		
		this.subscribe("window.xf.CheckReportItemVisibilityChanged",this.onRefreshList,this)
		this.subscribe("window.xf.CheckReportContentChanged",this.onRefreshList,this)
		this.subscribe("window.xf.Content162Changed",this.onRefreshList,this)
		this.on('beforedestroy',function() {
		      this.unsubscribe()
		},this)
		
		panel.xf.CheckReportResultGridPanel.superclass.initComponent.apply(this,arguments)
	},
	render : function() {
		panel.xf.CheckReportResultGridPanel.superclass.render.apply(this,arguments)
		
		if (!this.readOnly) {
			this.grid.on('afteredit', this.onAfterEdit, this)	
			
			this.grid.addListener("cellclick", function(ele,r,c,e){
				this.grid.startEditing(r,c)
			},this)
		}
	},	
	getListDefinitions : function() {
		return [{
			name : 'id'
		},{
			name : 'check_report_id'
		},{
			name : 'check_report_system_id'
		},{
			name : 'content_item_code'
		},{
			name : 'content_order_number'
		},{
			name : 'code'
		},{
			name : 'content_item_name',
			header : '项目',
			type : 'string',
			sortable : false
		},{
			name : 'content_name',
			header : '检测内容',
			type : 'string',
			width : 370,
    		renderer : this.wordWrapRender.createDelegate(this),
			sortable : false
		},{
			name : 'check_result',
			header : '检测结果',
			type : 'string',
			width : 120,
			sortable : false,
            editor: this.readOnly?undefined:new Ext.form.ComboBox(this.getCombo())
		},{
			name : 'check_descrip',
			header : '检测说明',
			width : 150,
			type : 'string',
			sortable : false,
			renderer : this.lineBreakRender.createDelegate(this),
            editor: this.readOnly?undefined:new Ext.form.TextArea({
			   grow : true,
			   growMin: 20
            })
		}]
	},
	getCombo : function(fldName) {
		var data = []
		data.push({
			value : "",
			display : "--无--"
		})
		data.push({
			value : "合格",
			display : "合格"
		})
		data.push({
			value : "不合格",
			display : "不合格"
		})
		if (this.checkReport && this.checkReport.check_type_name=="年度检测")
		    data.push({
		        value : '不属本次检测范围',
		        display : '不属本次检测范围'
		    })
		var ds = new divo.data.SimpleListStore({
			id : "value",
			fields : [{
				name : "value"
			}, {
				name : "display"
			}],
			data : data
		})
		return {
			store : ds,
			valueField : "value",
			displayField : "display",
			typeAhead : false,
			mode : "local",
			triggerAction : "all",
			emptyText : "",
			selectOnFocus : true,
			hidden : false,
			editable : false
		}
	},
	onAfterEdit : function(e) {
		var record = e.record.data
        var ok = true
        Ext.Ajax.request({
        	scope : this,
        	url : "/xf/checkreports/"+this.checkReportId+"/system/"+this.systemId+"/results/"+record.id,
        	async : false,
        	method : 'PUT',
        	jsonData : {checkResult:record.check_result,
        				checkDescrip:record.check_descrip},
        	success : function(response, options) {
        		var resp = Ext.decode(response.responseText)
        		if (resp.success) 
        			this.ds.commitChanges()
        	},
        	failure : function(response, options) {
        		this.alert(response.responseText)
        		ok = false
        	}
        })
        if (!ok) {
			this.ds.rejectChanges()
		}
	},
	createToolbarBtn : function(){
		var tb = [];

		var addContent106Btn = new Ext.Toolbar.Button( {
			text : '添加喷淋泵组',
			icon : divo.iconUrl + "add_file.gif",
			cls : 'x-btn-text-icon',
			hidden : this.readOnly,
			handler : this.addContent106.createDelegate(this)
		})
		var addBtn = new Ext.Toolbar.Button( {
			text : '添加检测内容',
			icon : divo.iconAdd,
			cls : 'x-btn-text-icon',
			hidden : this.readOnly || this.checkReport.report_type==2, //钢结构不能添加检测内容 
			handler : this.addContent.createDelegate(this)
		})
		var seleBtn = new Ext.Toolbar.Button( {
			text : '选择检测项目',
			icon : divo.iconSearch,
			cls : 'x-btn-text-icon',
			hidden : this.readOnly || this.checkReport.report_type==2, //钢结构不能选择检测项目 
			handler : this.selectItem.createDelegate(this)
		})
		tb.push('->')
		if (this.systemCode && this.systemCode=="106") {
			tb.push(addContent106Btn)
		}
		tb.push(addBtn)
		tb.push(seleBtn)
		return tb
	},
	selectItem : function() {
		var win = new window.xf.CheckReportItemVisibilityWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReportId,
			systemId : this.systemId	
		})
		win.show()
	},
	addContent : function() {
		if (!this.cId) {
			this.say("请先选中要添加检测内容的位置")
			return
		}
		var data = this.cRecordData
		var win = new window.xf.CheckReportContentWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			contentData : this.cRecordData
		})
		win.show()
	},
	addContent106 : function() {
		var win = new window.xf.CheckReportContent162Window({
			closeAction : "destroy",
			cancelAction : "destroy",
			hasContent : this.ds.getTotalCount() > 0,
			checkReportId : this.checkReportId,
			systemId : this.systemId
		})
		win.show()
	}
	
})

Ext.reg('panel.xf.CheckReportResultGridPanel', panel.xf.CheckReportResultGridPanel)
// EOP

;/**
 * 用户添加、修改和删除自定义的检测内容
 */
panel.xf.CheckReportContentGridPanel = Ext.extend(divo.panel.SmartGridPanel, {
	contentData : null,
	initComponent : function() {
		this.url = '/xf/checkreports/'+this.contentData.check_report_id+
 				   '/system/'+this.contentData.check_report_system_id+
 				   '/items/'+this.contentData.content_item_code+'/contents'
		Ext.apply(this, {
			fieldDefinitions : this.getListDefinitions(),
			url : this.url,
			gridConfig : {
				gridIdOfView : 'xf-check-report-content-grid',
				footer : false,
				filter : false,
				toolbar : this.createToolbarBtn(),
				displayLoadMask : true,
				groupField : 'content_item_name',
				groupSortInfo : {field: 'content_order_number', direction: "ASC"},
				editorGrid : true,
				hideHeaders : true,
				allowGridState : false //程序中指定列宽
			},
			autoScroll : true
		})
		
		panel.xf.CheckReportContentGridPanel.superclass.initComponent.apply(this,arguments)
	},
	render : function() {
		panel.xf.CheckReportContentGridPanel.superclass.render.apply(this,arguments)
		
		this.grid.on('beforeedit', this.onBeforeEdit, this)	
		this.grid.on('afteredit', this.onAfterEdit, this)	
	},	
	getListDefinitions : function() {
		return [{
			name : 'id'
		},{
			name : 'check_report_id'
		},{
			name : 'check_report_system_id'
		},{
			name : 'content_item_code'
		},{
			name : 'user_added'
		},{
			name : 'content_item_name',
			header : '项目',
			type : 'string',
			sortable : false
		},{
			name : 'content_order_number'
		},{
			name : 'content_name',
			header : '检测内容',
			type : 'string',
			width : 270,
    		renderer : this.contentNameRender.createDelegate(this),
            editor: new Ext.form.TextField(),
			sortable : false
		}]
	},
	contentNameRender : function(value,metadata,record,rowIndex,colIndex){
		if (!record.data.user_added)
			metadata.css = "check-report-content-not-user-added"
		return this.wordWrapRender(value,metadata,record,rowIndex,colIndex)
	},
	onBeforeEdit : function(e) {
		var r = e.record.data
		if (!r.user_added)
		    return false
	},
	onAfterEdit : function(e) {
		var r = e.record.data
		if (r.content_name.length==0) {
			this.say("请输入检测内容")
			return	
		}
        var ok = true
        Ext.Ajax.request({
        	scope : this,
        	url : this.url+(r.id?"/"+r.id:""),
        	async : false,
        	method : r.id?'PUT':'POST',
        	jsonData : {content_name:r.content_name},
        	success : function(response, options) {
        		var resp = Ext.decode(response.responseText)
        		if (resp.success) { 
        			this.ds.commitChanges()
        			this.cIdFocus = resp.id
        			this.loadList()
        		}	
        	},
        	failure : function(response, options) {
        		this.alert(response.responseText)
        		ok = false
        	}
        })
        if (!ok) {
			this.ds.rejectChanges()
		}
	},
	createToolbarBtn : function(){
		var tb = [];

		var addBtn = new Ext.Toolbar.Button( {
			text : '添加',
			icon : divo.iconAdd,
			cls : 'x-btn-text-icon',
			handler : this.addContent.createDelegate(this)
		})
		var updateBtn = new Ext.Toolbar.Button( {
			text : '修改',
			icon : divo.iconEdit,
			cls : 'x-btn-text-icon',
			handler : this.startEditContent.createDelegate(this)
		})
		var deleteBtn = new Ext.Toolbar.Button( {
			text : '删除',
			icon : divo.iconDelete,
			cls : 'x-btn-text-icon',
			handler : this.deleteContent.createDelegate(this)
		})
		var upBtn = new Ext.Toolbar.Button( {
			tooltip : '向上移动',
			icon : divo.iconUrl + 'arrow_up.gif',
			cls : 'x-btn-icon',
			handler : this.moveUp.createDelegate(this)
		})
		var dnBtn = new Ext.Toolbar.Button( {
			tooltip : '向下移动',
			icon : divo.iconUrl + 'arrow_down.gif',
			cls : 'x-btn-icon',
			handler : this.moveDown.createDelegate(this)
		})
		tb.push(addBtn)
		tb.push(updateBtn)
		tb.push(deleteBtn)
		tb.push('-')
		tb.push(upBtn)
		tb.push(dnBtn)
		return tb
	},
	addContent : function() {
    	var Rec = Ext.data.Record.create([
		{
			name : 'check_report_id'
		},{
			name : 'check_report_system_id'
		},{
			name : 'content_item_code',
			type: 'string'
		},{
			name : 'user_added',
			type: 'bool'
		},{
			name : 'content_item_name',
			type: 'string'
		},{
			name : 'content_order_number'
		},{
			name : 'content_name',
			type: 'string'
		}])
		var p = new Rec({
                check_report_id: this.contentData.check_report_id,
                check_report_system_id: this.contentData.check_report_system_id,
                content_item_code: this.contentData.content_item_code,
                user_added: true,
                content_item_name: this.contentData.content_item_name,
                content_order_number: 0,
                content_name: ""
        })
        this.grid.stopEditing()
        this.ds.insert(0, p)
        //this.selModel.selectFirstRow()
        //this.grid.startEditing(0,0) # rowIndex,colIndex
		var cIndex = this.grid.getColumnModel().findColumnIndex('content_name')
		this.grid.startEditing.defer(200, this.grid, [0,cIndex])
	},
	startEditContent : function() {
		if (!this.cId) {
			this.say("请先选择检测内容")
			return
		}
		if (!this.cRecordData.user_added) {
			this.say("只能修改添加的检测内容")
			return
		}
		var cIndex = this.grid.getColumnModel().findColumnIndex('content_name')
        this.grid.startEditing(this.cRowIndex,cIndex)
	},
	deleteContent : function() {
		if (!this.cId) {
			this.say("请先选择检测内容")
			return
		}
		if (!this.cRecordData.user_added) {
			this.say("只能删除新添加的检测内容")
			return
		}
		var ok = true
		Ext.Ajax.request({
			scope : this,
			url : this.url+'/'+this.cId,
			async : false,
			method : 'DELETE',
			failure : function(response, options) {
				this.alert(response.responseText)
				ok = false
			}
		})
		if (ok) {
			this.loadList()
		}
	},
	moveUp : function() {
		if (!this.cId) {
			this.say("请先选择检测内容")
			return
		}
		Ext.Ajax.request({
			scope : this,
			url : this.url+'/'+this.cId+"/up",
			async : false,
			method : 'PUT',
			jsonData : {aa:1}
		})
		this.loadList()
	},
	moveDown : function() {
		if (!this.cId) {
			this.say("请先选择检测内容")
			return
		}
		Ext.Ajax.request({
			scope : this,
			url : this.url+'/'+this.cId+"/down",
			async : false,
			method : 'PUT',
			jsonData : {aa:1}
		})
		this.loadList()
	}
	
})

Ext.reg('panel.xf.CheckReportContentGridPanel', panel.xf.CheckReportContentGridPanel)
// EOP

;/**
 * 检测项目选择网格
 */
panel.xf.CheckReportItemVisibilityGridPanel = Ext.extend(divo.panel.SmartGridPanel, {
	checkReportId : null,
	systemId : null,	
	initComponent : function() {
		Ext.apply(this, {
			fieldDefinitions : this.getListDefinitions(),
			url : '/xf/checkreports/'+this.checkReportId+'/system/'+this.systemId+"/items",
			gridConfig : {
				gridIdOfView : 'xf-check-report-items-grid',
				footer : false,
				filter : false,
				displayLoadMask : true,
				editorGrid : true
			},
			autoScroll : true
		})
		
		panel.xf.CheckReportItemVisibilityGridPanel.superclass.initComponent.apply(this,arguments)
	},
	render : function() {
		panel.xf.CheckReportItemVisibilityGridPanel.superclass.render.apply(this,arguments)
		
		this.grid.addListener("cellclick", function(o, row, cell, e){
			  if (o.getColumnModel().getDataIndex(cell) == 'visible' && e.getTarget('.checkbox', 1)) {
		        	var rec = o.getStore().getAt(row);
		        	rec.set('visible', !rec.get('visible')); 
		        	this.save(rec.data)
		      }
		},this) //Thanks: http://extjs.com/forum/showthread.php?t=5864&page=2		
	},	
	getListDefinitions : function() {
		return [{
			name : 'id'
		},{
			name : 'item_name',
			header : '项目',
			type : 'string',
			sortable : false
		},{
			name : 'visible',
			header : '选中?',
			type : 'bool',
			sortable : false,
            renderer : this.booleanRender.createDelegate(this)
		}]
	},
	save : function(record) {
        var ok = true
        Ext.Ajax.request({
        	scope : this,
        	url : "/xf/checkreports/"+this.checkReportId+"/system/"+this.systemId+"/items/"+record.id+"/visibility",
        	async : false,
        	method : 'PUT',
        	jsonData : {aa:1},
        	success : function(response, options) {
        		var resp = Ext.decode(response.responseText)
        		if (resp.success) 
        			this.ds.commitChanges()
        		else
        		    ok = false
        	},
        	failure : function(response, options) {
        		//this.alert(response.responseText)
        		ok = false
        	}
        })
        if (!ok) {
			this.ds.rejectChanges()
		}
	},
	booleanRender : function(value, cell, rec, rowIndex, colIndex, ds) {
	  return [
	    '<img ',
	      'class="checkbox" ', 
	      'src="media/js/ext/resources/images/default/menu/',
	      value? 'checked.gif' : 'unchecked.gif',
	    '"/>'
	  ].join("");
	}
	
})

Ext.reg('panel.xf.CheckReportItemVisibilityGridPanel', panel.xf.CheckReportItemVisibilityGridPanel)
// EOP

;/**
 * 各系统设备清单维护
 */
panel.xf.CheckReportProductGridPanel = Ext.extend(divo.panel.SmartGridDetailPanel, {
	checkReportId : null,
	checkReportType : null,
	tryOutOnly : null,
	systemId : null,
	readOnly : null,
	initComponent : function() {
		this.corpInfo = this.getCorpInfo()
		this.action = new Ext.ux.grid.RowActions({
			header : '操作',
			autoWidth : false,
			width : 60,
			actions : [{
				iconCls : 'icon-update',
				tooltip : '修改产品',
				hide : this.readOnly
			}, {
				iconCls : 'icon-delete',
				tooltip : '删除产品',
				hide : this.readOnly
			}]
		})
		this.action.on('action', this.onAction, this)

		Ext.apply(this, {
			url : "/xf/checkreports/"+this.checkReportId+"/system/"+this.systemId+"/products",
			fieldDefinitions : this.getListDefinitions(),
			gridConfig : {
				gridIdOfView : 'xf-check-report-sys-product-grid',
				filter : false,
				toolbar : this.createToolbarBtn(),
				plugins : [this.action],
				groupField : 'device_name',
				groupSortInfo : {field: 'id', direction: "ASC"}
			},
			autoScroll : true
		})

		this.subscribe("window.xf.CheckReportProductChanged", this.onProductChanged, this)
		this.on('beforedestroy', function() {
			this.unsubscribe()
		}, this)

		panel.xf.CheckReportProductGridPanel.superclass.initComponent.apply(this,
				arguments)
	},
	createToolbarBtn : function(){
		var tb = [];

		var addBtn = new Ext.Toolbar.Button( {
			text : '添加',
			tooltip : '添加产品',
			icon : divo.iconAdd,
			cls : 'x-btn-text-icon',
			hidden : this.readOnly,
			handler : this.addItem.createDelegate(this)
		})
		tb.push(addBtn)
		return tb
	},
	onAction : function(grid, record, action, row, col) {
		if (action == 'icon-update')
			this.editItem()
		if (action == 'icon-delete')
			this.deleteItem()
	},
	// 重写
	createGridMeta : function() {
		return this.getGridMeta(this.fieldDefinitions,[this.action])
	},
	getListDefinitions : function() {
		return [{
			name : 'id'
		}, {
			name : 'device_name',
			header : '设备名称',
			type : 'string'
		}, {
			name : 'product_name',
			header : '名称',
			renderer: this.wordWrapRender.createDelegate(this),
			type : 'string'
		}, {
			name : 'product_spec',
			header : '型号',
			renderer: this.wordWrapRender.createDelegate(this),
			type : 'string'
		}, {
			name : 'product_cat_name_2',
			header : '类别',
			type : 'string'
		}, {
			name : 'amount',
			header : '数量',
			type : 'float'
		}, {
			name : 'product_unit_name',
			header : '单位',
			renderer: this.wordWrapRender.createDelegate(this),
			type : 'string'
		}, {
			name : 'product_producer_name',
			header : '生产单位',
			type : 'string'
		}]
	},
	addItem : function() {
		this.productWindowId = this.myId('win')

		var win = new window.xf.CheckReportProductAddOrEditWindow({
			id : this.productWindowId,
			closeAction : "destroy",
			cancelAction : "destroy",
			adding : true,
			checkReportId  : this.checkReportId,
			systemId : this.systemId,
			tryOutOnly : this.tryOutOnly,
			customHeight : this.tryOutOnly?450:250,
			checkReportType : this.checkReportType,
			winTitle : '添加产品'
		})
		win.show()
	},
	editItem : function() {
		if (!this.cId) {
			this.say("请先选择要修改的记录")
			return
		}
		this.productWindowId = this.myId('win')

		var win = new window.xf.CheckReportProductAddOrEditWindow({
			id : this.productWindowId,
			closeAction : "destroy",
			cancelAction : "destroy",
			adding : false,
			productRecordId : this.cId,
			checkReportId  : this.checkReportId,
			tryOutOnly : this.tryOutOnly,
			customHeight : this.tryOutOnly?450:250,
			systemId : this.systemId,
			checkReportType : this.checkReportType,
			winTitle : '修改产品'
		})
		win.show()
	},
	onProductChanged : function(subj, msg, data) {
		if (msg.sender == this.productWindowId) {
			this.cIdFocus = msg.id
			this.loadList()
		}
	},
	onDeleteItem : function(id) {
		Ext.Ajax.request({
			scope : this,
			url : this.url + "/" + this.cId,
			method : 'DELETE',
			success : function(response, options) {
				var resp = Ext.decode(response.responseText)
				if (resp.success)
					this.deleteItemCallback()
				else
					this.say(resp.errors.reason)
			},
			failure : function(response, options) {
				this.alert(response.responseText)
			}
		})
	}

})

Ext.reg('panel.xf.CheckReportProductGridPanel', panel.xf.CheckReportProductGridPanel)
// EOP

;/**
 * 检测依据选择网格
 */
panel.xf.CheckUnderGridPanel = Ext.extend(divo.panel.SmartGridPanel, {
	checkReportType : null,	
	initComponent : function() {
		Ext.apply(this, {
			fieldDefinitions : this.getListDefinitions(),
			url : '/xf/checkreports/types/'+this.checkReportType+"/checkunders",
			gridConfig : {
				gridIdOfView : 'xf-check-under-grid',
				footer : false,
				filter : false,
				displayLoadMask : true,
				checkboxSelectionModel : true
			},
			autoScroll : true
		})
		
		panel.xf.CheckUnderGridPanel.superclass.initComponent.apply(this,arguments)
	},	
	getListDefinitions : function() {
		return [{
			name : 'id'
		},{
			name : 'name',
			header : '名称',
			type : 'string',
			sortable : false
		}]
	},
	// 重写
	createGridMeta : function() {
		return this.getGridMeta(this.fieldDefinitions,this.isLookup?null:[new Ext.grid.CheckboxSelectionModel()])
	},
	//public
	getContent : function() {
	  	  var records = this.selModel.getSelections()
	      if(records.length==0){ 
	          this.say("请选择检测依据")
	          return null
	      } 
	      var content = []
	      for(var i=0;i <records.length;i++){ 
      	  	  var record = this.grid.getStore().getAt(i) 
              content.push(record.data.name) 
	      } 
	      return content.join('\n')
	}
	
})

Ext.reg('panel.xf.CheckUnderGridPanel', panel.xf.CheckUnderGridPanel)
// EOP

;/**
  * 检测项目选择网格：是否插入换页符
  * 
  * --------------------------------------------------------------
  * 消息：
  * 插入了换页符
  * 
  * 消息名：     			
  * panel.xf.CheckReportItemBrkLineChanged	    
  * 
  * 消息内容：
  * {String} sender 本组件的id值
  * --------------------------------------------------------------
 */
panel.xf.CheckReportItemBrkLineGridPanel = Ext.extend(divo.panel.SmartGridPanel, {
	checkReportId : null,
	systemId : null,	
	initComponent : function() {
		Ext.apply(this, {
			fieldDefinitions : this.getListDefinitions(),
			url : '/xf/checkreports/'+this.checkReportId+'/system/'+this.systemId+"/items",
			gridConfig : {
				gridIdOfView : 'xf-check-report-items-linebrk-grid',
				footer : false,
				filter : false,
				displayLoadMask : true,
				editorGrid : true
			},
			autoScroll : true
		})
		
		panel.xf.CheckReportItemBrkLineGridPanel.superclass.initComponent.apply(this,arguments)
	},
	//重写
	onBeforeLoad : function(store, options) {
		store.baseParams.onlyVisible = 1
		store.baseParams.allItem = 1
	},
	render : function() {
		panel.xf.CheckReportItemBrkLineGridPanel.superclass.render.apply(this,arguments)
		
		this.grid.addListener("cellclick", function(o, row, cell, e){
			  if (o.getColumnModel().getDataIndex(cell) == 'must_break_line' && e.getTarget('.checkbox', 1)) {
		        	var rec = o.getStore().getAt(row);
		        	rec.set('must_break_line', !rec.get('must_break_line')); 
		        	this.save(rec.data)
		      }
		},this) //Thanks: http://extjs.com/forum/showthread.php?t=5864&page=2
		this.loadList()
	},	
	getListDefinitions : function() {
		return [{
			name : 'id'
		},{
			name : 'item_name',
			header : '项目',
			type : 'string',
			sortable : false
		},{
			name : 'must_break_line',
			header : '换页?',
			type : 'bool',
			sortable : false,
            renderer : this.booleanRender.createDelegate(this)
		}]
	},
	save : function(record) {
        var ok = true
        Ext.Ajax.request({
        	scope : this,
        	url : "/xf/checkreports/"+this.checkReportId+"/system/"+this.systemId+"/items/"+record.id+"/breakline",
        	async : false,
        	method : 'PUT',
        	jsonData : {},
        	success : function(response, options) {
        		var resp = Ext.decode(response.responseText)
        		if (resp.success)  {
        			this.ds.commitChanges()
        			this.publish("panel.xf.CheckReportItemBrkLineChanged",{sender:this.id})
        		}
        	},
        	failure : function(response, options) {
        		//this.alert(response.responseText)
        		ok = false
        	}
        })
        if (!ok) {
			this.ds.rejectChanges()
		}
	},
	booleanRender : function(value, cell, rec, rowIndex, colIndex, ds) {
	  return [
	    '<img ',
	      'class="checkbox" ', 
	      'src="media/js/ext/resources/images/default/menu/',
	      value? 'checked.gif' : 'unchecked.gif',
	    '"/>'
	  ].join("");
	}
	
})

Ext.reg('panel.xf.CheckReportItemBrkLineGridPanel', panel.xf.CheckReportItemBrkLineGridPanel)
// EOP

;/**
 * 喷淋泵组定义网格
 */
panel.xf.CheckReportContent162GridPanel = Ext.extend(divo.panel.SmartGridDetailPanel, {
	checkReportId : null,
	systemId : null,
	hasContent : null,
	initComponent : function() {
		Ext.apply(this, {
			url : "/xf/checkreports/"+this.checkReportId+"/system/"+this.systemId+"/part162",
			fieldDefinitions : this.getListDefinitions(),
			gridConfig : {
				gridIdOfView : 'xf-check-report-content-162-grid',
				filter : false,
				footer : false,
				toolbar : this.createToolbarBtn(),
				allowGridState : false
			},
			autoScroll : true
		})

		this.subscribe("window.xf.CheckReportContent162Added", this.onContent162Added, this)
		this.on('beforedestroy', function() {
			this.unsubscribe()
		}, this)

		panel.xf.CheckReportContent162GridPanel.superclass.initComponent.apply(this,
				arguments)
	},
	createToolbarBtn : function(){
		var tb = [];

		var addBtn = new Ext.Toolbar.Button( {
			text : '添加',
			icon : divo.iconAdd,
			cls : 'x-btn-text-icon',
			hidden : this.readOnly,
			handler : this.addItem.createDelegate(this)
		})
		var deleteBtn = new Ext.Toolbar.Button( {
			text : '删除',
			icon : divo.iconDelete,
			cls : 'x-btn-text-icon',
			handler : this.deleteItem.createDelegate(this)
		})
		tb.push(addBtn)
		tb.push(deleteBtn)
		return tb
	},
	getListDefinitions : function() {
		return [{
			name : 'id'
		}, {
			name : 'order_number',
			header : '序号',
			width : 50,
			type : 'int'
		}, {
			name : 'item_name_list',
			header : '所属小系统',
			width : 400,
			renderer : this.wordWrapRender.createDelegate(this),
			type : 'string'
		}]
	},
	addItem : function() {
		//获取还可以选择的小系统
		var items = this.getItemsAvailable()
		if (items.length==0) {
			this.say("不能再添加喷淋泵组，因为小系统已经全部选择。")
			return
		}

		var win = new window.xf.CheckReportContent162AddOrEditWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			adding : true,
			checkReportId  : this.checkReportId,
			systemId : this.systemId,
			winTitle : '添加喷淋泵组',
			systemItems : items
		})
		win.show()
	},
	getItemsAvailable : function() {
		var items = []
		Ext.Ajax.request({
			scope : this,
			url : this.url+"/items/available",
			async : false,
			method : 'GET',
			success : function(response, options) {
				items = Ext.decode(response.responseText)
			},
			failure : function(response, options) {
				this.alert(response.responseText)
			}
		})
		return items
	},
	onContent162Added : function(subj, msg, data) {
 		this.cIdFocus = msg.id
		this.loadList()
	},
	onDeleteItem : function(id) {
		Ext.Ajax.request({
			scope : this,
			url : this.url + "/" + this.cId,
			method : 'DELETE',
			success : function(response, options) {
				var resp = Ext.decode(response.responseText)
				if (resp.success) {
					this.loadList()
				}
			},
			failure : function(response, options) {
				this.alert(response.responseText)
			}
		})
	}

})

Ext.reg('panel.xf.CheckReportContent162GridPanel', panel.xf.CheckReportContent162GridPanel)
// EOP

;/**
 * “系统之1：火灾自动报警系统”输入面板
 */
panel.xf.CheckReport101Panel = Ext.extend(panel.xf.CheckReportBasePanel, {
	getCheckReportItems : function() {
		return [{
			title : "概述",
			xtype : "form.xf.CheckReportHomeForm",
			checkReportId : this.checkReportId,
			tryOutOnly : this.checkReport.tryout_only,
			systemId : this.systemId,
			readOnly : this.readOnly
		}, {
			title : "示意图",
			xtype : "form.xf.CheckReportPicForm",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			readOnly : this.readOnly
		}, {
			title : "系统评述",
			xtype : "form.xf.CheckReportNoteForm",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			readOnly : this.readOnly
		}, {
			title : "系统检测记录附表",
			xtype : "panel.xf.CheckReportResultGridPanel",
			checkReportId : this.checkReportId,
			checkReport : this.checkReport,
			systemId : this.systemId,
			readOnly : this.readOnly
		}, {
			title : "设备清单",
			xtype : "panel.xf.CheckReportProductGridPanel",
			checkReportId : this.checkReportId,
			tryOutOnly : this.checkReport.tryout_only,
			systemId : this.systemId,
			checkReportType : this.checkReport.report_type,
			readOnly : this.readOnly
		}]
	}
})

Ext.reg("panel.xf.CheckReport101Panel", panel.xf.CheckReport101Panel)
// EOP

;/**
 * “系统之2：机械防排烟系统”输入面板
 */
panel.xf.CheckReport102Panel = Ext.extend(panel.xf.CheckReportBasePanel, {
	getCheckReportItems : function() {
		return [{
			title : "概述",
			xtype : "form.xf.CheckReportHome102Form",
			checkReportId : this.checkReportId,
			tryOutOnly : this.checkReport.tryout_only,
			systemId : this.systemId,
			readOnly : this.readOnly
		}, {
			title : "示意图",
			xtype : "form.xf.CheckReportPicForm",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			readOnly : this.readOnly
		}, {
			title : "系统评述",
			xtype : "form.xf.CheckReportNoteForm",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			readOnly : this.readOnly
		}, 
			this.createLayoutPanel(),
		{
			title : "设备清单",
			xtype : "panel.xf.CheckReportProductGridPanel",
			checkReportId : this.checkReportId,
			tryOutOnly : this.checkReport.tryout_only,
			systemId : this.systemId,
			checkReportType : this.checkReport.report_type,
			readOnly : this.readOnly
		}]
	},
	createLayoutPanel : function() {
		return new Ext.Panel({
			layout : 'border',
			defaults : {
				border : false
			},
			title : '系统检测记录附表',
			border : false,
			items : [{
				region : 'center',
				layout : 'fit',
				autoScroll : true,
				items : [{
					xtype : "panel.xf.CheckReportResultGridPanel",
					checkReportId : this.checkReportId,
					checkReport : this.checkReport,
					systemId : this.systemId,
					readOnly : this.readOnly
				}]
			}, {
				region : 'north',
				layout : 'fit',
				stateful : true,
				stateId : this.myId('north'),
				autoScroll : true,
				height : 150,
				split : true,
				items : [{
					id : this.myId('form'),
					xtype : "form.xf.CheckReportResult102Form",
					checkReportId : this.checkReportId,
					systemId : this.systemId,
					readOnly : this.readOnly
				}]
			}],
			checkReportResultFormId : this.myId('form'),
			save : function() {
				Ext.getCmp(this.checkReportResultFormId).save()
			}
		})
	}
})

Ext.reg("panel.xf.CheckReport102Panel", panel.xf.CheckReport102Panel)
// EOP

;/**
 * “系统之3：泡沫灭火系统”输入面板
 */
panel.xf.CheckReport103Panel = Ext.extend(panel.xf.CheckReportBasePanel, {
	getCheckReportItems : function() {
		return [{
			title : "概述",
			xtype : "form.xf.CheckReportHomeForm",
			checkReportId : this.checkReportId,
			tryOutOnly : this.checkReport.tryout_only,
			systemId : this.systemId,
			readOnly : this.readOnly
		}, {
			title : "示意图",
			xtype : "form.xf.CheckReportPicForm",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			readOnly : this.readOnly
		}, {
			title : "系统评述",
			xtype : "form.xf.CheckReportNoteForm",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			readOnly : this.readOnly
		}, {
			title : "系统检测记录附表",
			xtype : "panel.xf.CheckReportResultGridPanel",
			checkReportId : this.checkReportId,
			checkReport : this.checkReport,
			systemId : this.systemId,
			readOnly : this.readOnly
		}, {
			title : "设备清单",
			xtype : "panel.xf.CheckReportProductGridPanel",
			checkReportId : this.checkReportId,
			tryOutOnly : this.checkReport.tryout_only,
			checkReportType : this.checkReport.report_type,
			systemId : this.systemId,
			readOnly : this.readOnly
		}]
	}
})

Ext.reg("panel.xf.CheckReport103Panel", panel.xf.CheckReport103Panel)
// EOP

;/**
 * “系统之4：气体灭火系统”输入面板
 */
panel.xf.CheckReport104Panel = Ext.extend(panel.xf.CheckReportBasePanel, {
	getCheckReportItems : function() {
		return [{
			title : "概述",
			xtype : "form.xf.CheckReportHomeForm",
			tryOutOnly : this.checkReport.tryout_only,
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			readOnly : this.readOnly
		}, {
			title : "示意图",
			xtype : "form.xf.CheckReportPicForm",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			readOnly : this.readOnly
		}, {
			title : "系统评述",
			xtype : "form.xf.CheckReportNoteForm",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			readOnly : this.readOnly
		}, {
			title : "系统检测记录附表",
			xtype : "panel.xf.CheckReportResultGridPanel",
			checkReportId : this.checkReportId,
			checkReport : this.checkReport,
			systemId : this.systemId,
			readOnly : this.readOnly
		}, {
			title : "设备清单",
			xtype : "panel.xf.CheckReportProductGridPanel",
			checkReportId : this.checkReportId,
			tryOutOnly : this.checkReport.tryout_only,
			checkReportType : this.checkReport.report_type,
			systemId : this.systemId,
			readOnly : this.readOnly
		}]
	}
})

Ext.reg("panel.xf.CheckReport104Panel", panel.xf.CheckReport104Panel)
// EOP

;/**
 * “系统之5：室内外消火栓给水系统”输入面板
 */
panel.xf.CheckReport105Panel = Ext.extend(panel.xf.CheckReportBasePanel, {
	getCheckReportItems : function() {
		return [{
			title : "概述",
			xtype : "form.xf.CheckReportHomeForm",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			tryOutOnly : this.checkReport.tryout_only,
			readOnly : this.readOnly,
			projecterInputType : 2
		}, {
			title : "示意图",
			xtype : "form.xf.CheckReportPicForm",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			readOnly : this.readOnly
		}, {
			title : "系统评述",
			xtype : "form.xf.CheckReportNoteForm",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			readOnly : this.readOnly
		}, 
			this.createLayoutPanel(),
		{
			title : "设备清单",
			xtype : "panel.xf.CheckReportProductGridPanel",
			checkReportId : this.checkReportId,
			tryOutOnly : this.checkReport.tryout_only,
			checkReportType : this.checkReport.report_type,
			systemId : this.systemId,
			readOnly : this.readOnly
		}]
	},
	createLayoutPanel : function() {
		return new Ext.Panel({
			layout : 'border',
			defaults : {
				border : false
			},
			title : '系统检测记录附表',
			border : false,
			items : [{
				region : 'center',
				layout : 'fit',
				autoScroll : true,
				items : [{
					xtype : "panel.xf.CheckReportResultGridPanel",
					checkReportId : this.checkReportId,
					checkReport : this.checkReport,
					systemId : this.systemId,
					readOnly : this.readOnly
				}]
			}, {
				region : 'north',
				layout : 'fit',
				stateful : true,
				stateId : this.myId('north'),
				autoScroll : true,
				height : 150,
				split : true,
				items : [{
					id : this.myId('form'),
					xtype : "form.xf.CheckReportResult105Form",
					checkReportId : this.checkReportId,
					systemId : this.systemId,
					readOnly : this.readOnly
				}]
			}],
			checkReportResultFormId : this.myId('form'),
			save : function() {
				Ext.getCmp(this.checkReportResultFormId).save()
			}
		})
	}
	
})

Ext.reg("panel.xf.CheckReport105Panel", panel.xf.CheckReport105Panel)
// EOP

;/**
 * “系统之6：自动喷水灭火系统”输入面板
 */
panel.xf.CheckReport106Panel = Ext.extend(panel.xf.CheckReportBasePanel, {
	getCheckReportItems : function() {
		return [{
			title : "概述",
			xtype : "form.xf.CheckReportHomeForm",
			checkReportId : this.checkReportId,
			tryOutOnly : this.checkReport.tryout_only,
			systemId : this.systemId,
			readOnly : this.readOnly
		}, {
			title : "示意图",
			xtype : "form.xf.CheckReportPicForm",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			readOnly : this.readOnly
		}, {
			title : "系统评述",
			xtype : "form.xf.CheckReportNoteForm",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			readOnly : this.readOnly
		}, 
			this.createLayoutPanel(),
		{
			title : "设备清单",
			xtype : "panel.xf.CheckReportProductGridPanel",
			checkReportId : this.checkReportId,
			tryOutOnly : this.checkReport.tryout_only,
			checkReportType : this.checkReport.report_type,
			systemId : this.systemId,
			readOnly : this.readOnly
		}]
	},
	createLayoutPanel : function() {
		return new Ext.Panel({
			layout : 'border',
			defaults : {
				border : false
			},
			title : '系统检测记录附表',
			border : false,
			items : [{
				region : 'center',
				layout : 'fit',
				autoScroll : true,
				items : [{
					xtype : "panel.xf.CheckReportResultGridPanel",
					checkReportId : this.checkReportId,
					checkReport : this.checkReport,
					systemId : this.systemId,
					systemCode : '106',
					readOnly : this.readOnly
				}]
			}, {
				region : 'north',
				layout : 'fit',
				stateful : true,
				stateId : this.myId('south'),
				autoScroll : true,
				height : 150,
				split : true,
				items : [{
					id : this.myId('form'),
					xtype : "form.xf.CheckReportResult106Form",
					checkReportId : this.checkReportId,
					systemId : this.systemId,
					readOnly : this.readOnly
				}]
			}],
			checkReportResultFormId : this.myId('form'),
			save : function() {
				Ext.getCmp(this.checkReportResultFormId).save()
			}
		})
	}
	
})

Ext.reg("panel.xf.CheckReport106Panel", panel.xf.CheckReport106Panel)
// EOP

;/**
 * “系统之7：细水雾灭火系统”输入面板
 */
panel.xf.CheckReport107Panel = Ext.extend(panel.xf.CheckReportBasePanel, {
	getCheckReportItems : function() {
		return [{
			title : "概述",
			xtype : "form.xf.CheckReportHomeForm",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			tryOutOnly : this.checkReport.tryout_only,
			readOnly : this.readOnly
		}, {
			title : "示意图",
			xtype : "form.xf.CheckReportPicForm",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			readOnly : this.readOnly
		}, {
			title : "系统评述",
			xtype : "form.xf.CheckReportNoteForm",
			checkReportId : this.checkReportId,
			checkReport : this.checkReport,
			systemId : this.systemId,
			readOnly : this.readOnly
		}, {
			title : "系统检测记录附表",
			xtype : "panel.xf.CheckReportResultGridPanel",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			checkReport : this.checkReport,
			readOnly : this.readOnly
		}, {
			title : "设备清单",
			xtype : "panel.xf.CheckReportProductGridPanel",
			checkReportId : this.checkReportId,
			checkReportType : this.checkReport.report_type,
			tryOutOnly : this.checkReport.tryout_only,
			systemId : this.systemId,
			readOnly : this.readOnly
		}]
	}
})

Ext.reg("panel.xf.CheckReport107Panel", panel.xf.CheckReport107Panel)
// EOP

;/**
 * “系统之201：钢结构防火喷涂施工质量检测记录表”输入面板
 */
panel.xf.CheckReport201Panel = Ext.extend(panel.xf.CheckReportBasePanel, {
	getCheckReportItems : function() {
		return [{
			title : "概述",
			xtype : "form.xf.CheckReportHomeForm",
			checkReportId : this.checkReportId,
			tryOutOnly : this.checkReport.tryout_only,
			systemId : this.systemId,
			readOnly : this.readOnly
		}, {
			title : "系统评述",
			xtype : "form.xf.CheckReportNoteForm",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			readOnly : this.readOnly
		}, 
			this.createLayoutPanel(),
		{
			title : "设备清单",
			xtype : "panel.xf.CheckReportProductGridPanel",
			checkReportId : this.checkReportId,
			tryOutOnly : this.checkReport.tryout_only,
			checkReportType : this.checkReport.report_type,
			systemId : this.systemId,
			readOnly : this.readOnly
		}]
	},
	createLayoutPanel : function() {
		return new Ext.Panel({
			layout : 'border',
			defaults : {
				border : false
			},
			title : '系统检测记录附表',
			border : false,
			items : [{
				region : 'center',
				layout : 'fit',
				autoScroll : true,
				items : [{
					xtype : "panel.xf.CheckReportResultGridPanel",
					checkReportId : this.checkReportId,
					checkReport : this.checkReport,
					systemId : this.systemId,
					readOnly : this.readOnly
				}]
			}, {
				region : 'south',
				layout : 'fit',
				stateful : true,
				stateId : this.myId('north'),
				autoScroll : true,
				height : 150,
				split : true,
				items : [{
					id : this.myId('form'),
					xtype : "form.xf.CheckReportResult201Form",
					checkReportId : this.checkReportId,
					systemId : this.systemId,
					readOnly : this.readOnly
				}]
			}]
		})
	}
})

Ext.reg("panel.xf.CheckReport201Panel", panel.xf.CheckReport201Panel)
// EOP

;/**
 * 检测报告新建或修改表单
 */
form.xf.CheckReportAddOrEditForm = Ext.extend(divo.form.AddOrEditForm, {
	initFocusFldName : 'code',
	checkReportId : null,
	checkerId : null,
	initComponent : function() {
		Ext.apply(this, {
			labelWidth : 100,
			defaultType : "textfield",
			labelAlign : "right",
			autoScroll : true,
			bodyStyle : "padding:10px",
			items : [{
				xtype : "radiogroup",
				fieldLabel : "检测报告类型",
				columns: 1,
				items: [
                    {boxLabel: '上海市建筑消防设施检测报告', name: 'report_type',inputValue: 1, checked: true},
                    {boxLabel: '钢结构防火喷涂施工质量检测报告', name: 'report_type',inputValue: 2}
                ]
				},{
				xtype : 'datefield',
				format : 'Y',
				fieldLabel : divo.required+"检测报告年度",
                hidden : !this.adding,
				name : "year",
				value : new Date()
				},{
				xtype : "radiogroup",
				width : 270,
				fieldLabel : "检测类别",
				items: [
                    {boxLabel: '验收检测', name: 'check_type_name',inputValue: '验收检测', checked: true},
                    {boxLabel: '年度检测', name: 'check_type_name',inputValue: '年度检测'},
                    {boxLabel: '委托检测', name: 'check_type_name',inputValue: '委托检测'}
                ]
				},{
				fieldLabel : divo.required+"工程名称",
				name : "project_name",
				width : 350
			}]
		})

		form.xf.CheckReportAddOrEditForm.superclass.initComponent.call(this);
	},
	//重写
    loadItem : function() {
		Ext.Ajax.request({
			scope : this,
			url : "/xf/checkreports/"+this.checkReportId,
			method : 'GET',
			success : function(response, options) {
				var resp = Ext.decode(response.responseText);
				this.getForm().setValues(resp.data)
				
				this.checkerId = resp.data.checker_id
			},
			failure : function(response, options) {
				this.alert(response.responseText);
			}
		})
    },
	// public
	save : function(callbackOnSuccess) {
		var item = this.getForm().getObjectValues()
		item.userId = this.getUserId()
		item.userName = this.getUserFullName()
		item.checker_id = this.checkerId
		item.tryout_only = divo.hasPermission("CheckReportTryout")
		
		Ext.Ajax.request({
			scope : this,
			url : "/xf/checkreports"+(this.adding?"":"/"+this.checkReportId),
			waitMsg : "正在提交...",
			method : (this.adding?'POST':'PUT'),
			jsonData : item,
			success : function(response, options) {
				var resp = Ext.decode(response.responseText);
				if (!resp.success) {
					this.getForm().markInvalid(resp.errors)
				} else {
					callbackOnSuccess(resp.id)
				}
			},
			failure : function(response, options) {
				this.alert(response.responseText)	
			}
		})
	}
})

Ext.reg("form.xf.CheckReportAddOrEditForm", form.xf.CheckReportAddOrEditForm)
// EOP

;/**
 * 检测报告总表输入表单
 */
form.xf.CheckReportMasterForm = Ext.extend(divo.form.AutoSaveForm, {
	checkReportId : null,
	checkReportType : null,
	initFocusFldName : 'project_address',
	readOnly : false,
	initComponent : function() {

		Ext.apply(this, {
			labelWidth : 150,
			defaultType : "textfield",
			labelAlign : "right",
			autoScroll : true,
			bodyStyle : "padding:10px",
			layout : 'autotableform',
			items : [{
				fieldLabel : divo.required,
				labelSeparator : "",
				xtype : 'formHtml',
				hidden : this.readOnly,
				value : '为了保证报告打印质量，对于多行文本，请使用回车换行。'
			},{
				xtype : "combo",
				fieldLabel : "检测类别",
				hiddenName : "check_type_name",
				plugins: [new Ext.ux.FieldReadOnlyPlugin()],
				width : 150,
				store : new divo.data.SimpleListStore({
					id : "value",
					fields : [{
						name : "value"
					}, {
						name : "display"
					}],
					data : [{
						value : "验收检测",
						display : "验收检测"
					}, {
						   value : "年度检测",
						display : "年度检测"
					}, {
						value : "委托检测",
						display : "委托检测"
					}]
					}),
				valueField : "value",
				displayField : "display",
				typeAhead : false,
				mode : "local",
				triggerAction : "all",
				emptyText : "请选择",
				selectOnFocus : true,
				anchor : "100%",
				hidden : false,
				editable : false
			}, {
				fieldLabel :divo.required+'工程名称',
				readOnly : this.readOnly,
				name : 'project_name',
				width : 500
			}, {
				fieldLabel : '地址',
				readOnly : this.readOnly,
				name : 'project_address',
				width : 500
			}, {
				fieldLabel : '委托单位',
				readOnly : this.readOnly,
				name : 'project_client',
				width : 500
			}, {
				fieldLabel : '联系人',
				readOnly : this.readOnly,
				name : 'project_linkman',
				items : [{
					labelWidth : 150,
					readOnly : this.readOnly,
					fieldLabel : '联系电话',
					name : 'project_tele'
				}]
			}, {
				xtype : 'textarea',
				fieldLabel : '消防审核批准文号',
				name : 'project_audit_code',
				readOnly : this.readOnly,
				grow : true,
				width : 500
			}, {
				xtype : 'textarea',
				fieldLabel : '审图通过证书号',
				name : 'project_pic_check_code',
				readOnly : this.readOnly,
				grow : true,
				width : 500
			}, {
				xtype : "combo",
				fieldLabel : divo.required+"使用性质",
				hiddenName : "project_usage",
				plugins: [new Ext.ux.FieldReadOnlyPlugin()],
				width : 150,
				store : new divo.data.SimpleListStore({
					id : "value",
					fields : [{
						name : "value"
					}, {
						name : "display"
					}],
					data : [{
						value : "商场",
						display : "商场"
					}, {
						value : "商住楼",
						display : "商住楼"
					}, {
						value : "综合楼(带商场)",
						display : "综合楼(带商场)"
					}, {
						value : "综合楼(不带商场)",
						display : "综合楼(不带商场)"
					}, {
						value : "办公楼，科研楼",
						display : "办公楼，科研楼"
					}, {
						value : "宾馆，旅馆",
						display : "宾馆，旅馆"
					}, {
						value : "医院",
						display : "医院"
					}, {
						value : "学校",
						display : "学校"
					}, {
						value : "居住建筑",
						display : "居住建筑"
					}, {
						value : "厂房",
						display : "厂房"
					}, {
						value : "仓库",
						display : "仓库"
					}, {
						value : "其他",
						display : "其他"
					}]
				}),
				valueField : "value",
				displayField : "display",
				typeAhead : false,
				mode : "local",
				triggerAction : "all",
				emptyText : "请选择",
				selectOnFocus : true,
				anchor : "100%",
				hidden : false,
				editable : false,
				items : [{
					labelWidth : 150,
					xtype : "combo",
					fieldLabel : divo.required+"工程类别",
					hiddenName : "project_type",
				    plugins: [new Ext.ux.FieldReadOnlyPlugin()],
					width : 150,
					store : new divo.data.SimpleListStore({
						id : "value",
						fields : [{
							name : "value"
						}, {
							name : "display"
						}],
						data : [{
							value : "新建",
							display : "新建"
						}, {
							value : "改建",
							display : "改建"
						}, {
							value : "扩建",
							display : "扩建"
						}, {
							value : "内装修",
							display : "内装修"
						}]
					}),
					valueField : "value",
					displayField : "display",
					typeAhead : false,
					mode : "local",
					triggerAction : "all",
					emptyText : "请选择",
					selectOnFocus : true,
					anchor : "100%",
					hidden : false,
					editable : false
				}]
			},{	
				fieldLabel : "建筑物",
				text : '添加...',
				xtype : this.readOnly?'formHtml':'formBtn',
				handler : this.showAddBuildingWin,
				scope : this
			},{	
				hideLabel : true,
				xtype : 'formHtml',
				value : '<div id="'+this.myId("building")+'">'+this.showBuildings()+'</div>'
			}, {
				xtype : 'numberfield',
				fieldLabel : divo.required+"总建筑面积(平方米)",
				readOnly : this.readOnly,
				name : "building_area",
				decimalPrecision : 2,
				allowNegative : 2,
				width : 150,
				maxLength : 12
			}, {
				xtype : 'textarea',
				fieldLabel : "检测范围",
				name : "check_scope",
				readOnly : this.readOnly,
				width : 500,
				grow : true
			}, {
				xtype : 'datefield',
				fieldLabel : divo.required+'检测起止日期',
				plugins: [new Ext.ux.FieldReadOnlyPlugin()],
				name : 'start_date',
				format : 'Y.m.d',
				items : [{
					hideLabel : true,
					labelWidth : 20,
					xtype : 'formHtml',
					value : '～'
				}, {
					hideLabel : true,
  				    plugins: [new Ext.ux.FieldReadOnlyPlugin()],
					xtype : 'datefield',
					format : 'Y.m.d',
					name : 'end_date'
				}]
			},{
				xtype : 'checkbox',
				boxLabel : '以下内容打印在下一页',
				labelSeparator: '',
				name : "general_must_brk_page",
				hidden : this.readOnly,
				listeners : {
					check : this.onBrkPageChecked.createDelegate(this),
					scope : this
				}	
			}, {
				xtype : 'textarea',
				fieldLabel : "检测项目",
				name : "check_item",
				readOnly : this.readOnly,
				anchor : '100%',
				width : 500,
				grow : true
			}, {
				fieldLabel : "检测综合评定",
				text : '选择...',
				xtype : this.readOnly | this.checkReportType == 1 ? 'formHtml':'formBtn',
				handler : this.showCheckDescripWin,
				scope : this
			}, {
				xtype : 'textarea',
				fieldLabel : "",
				labelSeparator : "",
				readOnly : this.readOnly,
				name : "descrip",
				anchor : '100%',
				width : 500,
				grow : true
			}, {
				xtype : 'textarea',
				fieldLabel : "备注",
				readOnly : this.readOnly,
				name : "note",
				anchor : '100%',
				width : 500,
				grow : true
			}, {
				fieldLabel : "附录",
				xtype : 'formHtml',
				hidden : this.readOnly,
				value : '请选择相关的检测依据，并填写检测工具的使用情况。'
			}, {
				fieldLabel : "",
				labelSeparator : "",
				text : '选择...',
				xtype : this.readOnly?'formHtml':'formBtn',
				handler : this.showCheckUnderWin,
				scope : this
			}, {
				xtype : 'textarea',
				fieldLabel : "",
				labelSeparator : "",
				readOnly : this.readOnly,
				name : "appendix",
				anchor : '100%',
				width : 500,
				grow : true
			}, {
				xtype : 'datefield',
				format : 'Y.m.d',
				fieldLabel : divo.required+"签发日期",
				plugins: [new Ext.ux.FieldReadOnlyPlugin()],
				name : "report_date"
			}, {
				fieldLabel : divo.required+'批准人',
				readOnly : this.readOnly,
				name : 'approve_by',
				items : [{
					labelWidth : 150,
					readOnly : this.readOnly,
					fieldLabel : divo.required+'现场检测负责人',
					name : 'check_by'
				}]
			}, {
				fieldLabel : divo.required+'审核人',
				readOnly : this.readOnly,
				name : 'audit_by',
				items : [{
					labelWidth : 150,
					readOnly : this.readOnly,
					fieldLabel :divo.required+ '资格证书编号',
					name : 'check_by_code'
				}]
			}]
		})

		this.url = "/xf/checkreports/" + this.checkReportId + "/master"
		
		this.subscribe("window.xf.CheckReportBuildingChanged",this.onShowBuildings,this)
		this.subscribe("window.xf.CheckUnderSelected",this.onCheckUnderSelected,this)
		this.subscribe("window.xf.CheckDescripSelected",this.onCheckDescripSelected,this)
		this.on('beforedestroy',function() {
		      this.unsubscribe()
		},this)
		
		form.xf.CheckReportMasterForm.superclass.initComponent.call(this)
	},
	onBrkPageChecked : function(o, checked) {
		Ext.Ajax.request({
			scope : this,
			url : this.url,
			async : false,
			method : 'PUT',
			jsonData : {general_must_brk_page:checked},
			failure : function(response, options) {
				this.alert(response.responseText)
			}
		})
	},
	//通过FieldReadOnlyPlugin设置只读字段
	setReadOnlyFlds : function(flds) {
		for (var i = 0; i < flds.length; i++) {
			var f = this.getForm().findField(flds[i])
			f.setReadOnly(this.readOnly)
		}
	},
	//重写
	initForm : function() {
		form.xf.CheckReportMasterForm.superclass.initForm.call(this)
		
		this.setReadOnlyFlds(["check_type_name",
							  "project_usage",
							  "start_date",
							  "project_type",
							  "end_date",
							  "report_date"])
		
		this.el.on({
			click : {
				stopEvent : false,
				delegate : 'a',
				scope : this,
				fn : function(e, target) {
					var ss = target.id.split("-")
					if (ss.length<3) return
					if (ss[ss.length-2]=='u') {
						this.showUpdateBuildingWindow(ss[ss.length-1])
					}
					if (ss[ss.length-2]=='d') {
						this.deleteBuilding(ss[ss.length-1])
					}
				}
			}
		}) 
	},
	getBuildings : function() {
		var data = []
		Ext.Ajax.request({
			scope : this,
			url : "/xf/checkreports/"+this.checkReportId+"/buildings",
			async : false,
			method : 'GET',
			success : function(response, options) {
				data = Ext.decode(response.responseText)
			}
		})
		return data
	},
	getBuildingOperationStr : function(id) {
		if (this.readOnly) return ""
        return '<a id="'+this.myId('-u-'+id)+'" href="#">'+
		        '<span style="TEXT-DECORATION: underline;cursor:hand;">修改</span></a>&nbsp;&nbsp;|&nbsp;&nbsp;'+
				'<a id="'+this.myId('-d-'+id)+'" href="#">'+
		        '<span style="TEXT-DECORATION: underline;cursor:hand;">删除</span></a>'
	},
	showAddBuildingWin : function() {
		var win = new window.xf.CheckReportBuildingAddOrEditWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReportId,
			winTitle : '添加建筑物',
			adding : true
		})
		win.show()
	},
	showUpdateBuildingWindow : function(id) {
		var win = new window.xf.CheckReportBuildingAddOrEditWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReportId,
			winTitle : '修改建筑物',
			adding : false,
			buildingRecordId : id
		})
		win.show()
	},
	deleteBuilding : function(id) {
		var ok = true
		Ext.Ajax.request({
			scope : this,
			url : "/xf/checkreports/"+this.checkReportId+"/buildings/"+id,
			async : false,
			method : 'DELETE',
			success : function(response, options) {
				var resp = Ext.decode(response.responseText)
				if (!resp.success) {
					ok = false
				    this.say(resp.errors.reason)
				}     
			},
			failure : function(response, options) {
				this.alert(response.responseText)
				ok = false
			}
		})
		if (ok) {
			this.onShowBuildings()
		}
	},
	onShowBuildings : function(subj, msg, data) {
		var el = Ext.get(this.myId("building"))
		el.dom.innerHTML = this.showBuildings()
	},
	showBuildings : function() {
		var data = this.getBuildings()
		if (data.length==0)  {
			return ""
		}
		var h = []
		h.push('<table class="divo-table" align="center" border="1" cellpadding="0" cellspacing="0" width="830"><tbody>')
       	h.push('<tr height="20"><td width="36" align="right">序号</td>')
       	h.push('<td width="200" align="center">名称</td>')
       	h.push('<td width="50" align="center">层数</td>')
       	h.push('<td width="80" align="center">高度(米)</td>')
       	h.push('<td width="150" align="center">建筑面积(平方米)</td>')
       	if (this.readOnly)
       		h.push('</tr>')
       	else	
       		h.push('<td width="80" align="center">操作</td></tr>')
        for (var i = 0; i < data.length; i++) {
        	v = data[i]
	       	h.push('<tr height="20"><td width="36" align="right">'+v.order_number+'</td>')
	       	h.push('<td width="200" align="center">'+v.name+'</td>')
	       	h.push('<td width="50" align="center">'+(v.floor_count?v.floor_count:'-')+'</td>')
	       	h.push('<td width="80" align="center">'+(v.height?v.height:'-')+'</td>')
	       	h.push('<td width="150" align="center">'+(v.building_area?v.building_area:'-')+'</td>')
	       	if (this.readOnly)
		       	h.push('</tr>')
		    else   	
		       	h.push('<td width="80" align="center">'+this.getBuildingOperationStr(v.id)+'</td></tr>')
        }   
        h.push('</tbody></table>')
        return h.join("")   
	},
	showCheckUnderWin : function() {
		var win = new window.xf.CheckUnderWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportType : this.checkReportType	
		})
		win.show()
	},
	showCheckDescripWin : function() {
		var win = new window.xf.CheckDescripWindow({
			closeAction : "destroy",
			cancelAction : "destroy"
		})
		win.show()
	},
	onCheckUnderSelected : function(subj, msg, data) {
		var fld = this.getForm().findField('appendix')
		fld.setValue(msg.content)
	},
	onCheckDescripSelected : function(subj, msg, data) {
		var fld = this.getForm().findField('descrip')
		fld.setValue(msg.content)
	}

})

Ext.reg("form.xf.CheckReportMasterForm", form.xf.CheckReportMasterForm)
// EOP

;/**
 * 系统示意图
 */
form.xf.CheckReportPicForm = Ext.extend(divo.form.AutoSaveForm, {
	checkReportId : null,
	systemId : null,
	readOnly : false,
	initComponent : function() {
		this.imageId = this.myId('image')
		this.picUrl = "/xf/checkreports/" + this.checkReportId + "/system/"
				+ this.systemId + "/pic?auth="
				+ Ext.Ajax.defaultHeaders.Authorization
		this.url = "/xf/checkreports/" + this.checkReportId + "/system/"
				+ this.systemId

		Ext.apply(this, {
			labelWidth : 250,
			defaultType : "textfield",
			labelAlign : "right",
			autoScroll : true,
			bodyStyle : "padding:10px",
			layout : 'autotableform',
			items : [{
				xtype : 'formBtn',
				fieldLabel : "建议使用JPEG、GIF或PNG图形格式",
				text : '上传图片',
				handler : this.uploadPic,
				hidden : this.readOnly,
				scope : this
			}, {
				xtype : 'checkbox',
				boxLabel : '示意图在报告中打印',
				labelSeparator : '',
				name : "pic_printed",
				hidden : this.readOnly,
				listeners : {
					check : this.onPrintedChecked.createDelegate(this),
					scope : this
				}
			}, {
				xtype : "combo",
				fieldLabel : "打印页数",
				hiddenName : "pic_page_count",
				hidden : this.readOnly,
				width : 50,
				store : new divo.data.SimpleListStore({
					id : "value",
					fields : [{
						name : "value"
					}, {
						name : "display"
					}],
					data : [{
						value : 1,
						display : "1"
					}, {
						value : 2,
						display : "2"
					}, {
						value : 3,
						display : "3"
					}]
				}),
				valueField : "value",
				displayField : "display",
				typeAhead : false,
				mode : "local",
				triggerAction : "all",
				emptyText : "请选择",
				selectOnFocus : true,
				anchor : "100%",
				hidden : false,
				editable : false,
				listeners : {
					change : this.onPrintCountChanged.createDelegate(this),
					scope : this
				}
			}, {
				xtype : 'formBtn',
				fieldLabel : "",
				labelSeparator : "",
				text : '删除图片',
				handler : this.deletePic,
				hidden : this.readOnly,
				scope : this
			}, {
				hideLabel : true,
				xtype : 'formHtml',
				value : '<img id="' + this.imageId + '" src="' + this.picUrl
						+ "&_dc=" + (new Date().getTime()) + '" />'
			}]
		})

		form.xf.CheckReportPicForm.superclass.initComponent.call(this);
	},
	uploadPic : function() {
		if (!this.uploadDialog) {
			this.uploadDialog = new Ext.ux.UploadDialog.Dialog({
				url : this.picUrl,
				reset_on_hide : false,
				allow_close_on_upload : true,
				upload_autostart : true
			})
			this.uploadDialog.on('uploadsuccess', this.onUploadSuccess, this)
		}
		this.uploadDialog.show()
	},
	onUploadSuccess : function(o, fileName, resp) {
		var el = Ext.get(this.imageId)
		el.dom.src = this.picUrl + "&_dc=" + (new Date().getTime())
	},
	beforeDestroy : function() {
		if (this.uploadDialog)
			Ext.destroy(this.uploadDialog)
		form.xf.CheckReportPicForm.superclass.beforeDestroy.apply(this,
				arguments)
	},
	deletePic : function() {
		Ext.MessageBox.confirm('确认', '要删除已经上传的图片吗？', this.onDeletePicConform
				.createDelegate(this))
	},
	onDeletePicConform : function(btn) {
		if (btn != 'yes')
			return

		var ok = true
		Ext.Ajax.request({
			scope : this,
			url : this.picUrl,
			async : false,
			method : 'DELETE',
			success : function(response, options) {
				var resp = Ext.decode(response.responseText)
				if (!resp.success) {
					ok = false
					this.say(resp.errors.reason)
				}
			},
			failure : function(response, options) {
				this.alert(response.responseText)
				ok = false
			}
		})
		if (ok)
			this.onUploadSuccess()
	},
	onPrintedChecked : function(o, checked) {
		Ext.Ajax.request({
			scope : this,
			url : this.url,
			async : false,
			method : 'PUT',
			jsonData : {
				pic_printed : checked
			},
			failure : function(response, options) {
				this.alert(response.responseText)
			}
		})
	},
	onPrintCountChanged : function(o, value) {
		Ext.Ajax.request({
			scope : this,
			url : this.url,
			async : false,
			method : 'PUT',
			jsonData : {
				pic_page_count : value
			},
			failure : function(response, options) {
				this.alert(response.responseText)
			}
		})
	}

})
Ext.reg("form.xf.CheckReportPicForm", form.xf.CheckReportPicForm)
// EOP

;/**
 * 系统概述
 */
form.xf.CheckReportHomeForm = Ext.extend(divo.form.AutoSaveForm, {
	checkReportId : null,
	tryOutOnly : null,
	systemId : null,
	initFocusFldName : 'descrip',
	readOnly : false,
	projecterInputType : 1, //1-必须选择 2-直接输入名称 3-无施工单位
	initComponent : function() {
		this.url = "/xf/checkreports/"+this.checkReportId+"/system/"+this.systemId
		
		var lovDisplay = [divo.t1 + '{name}' + divo.t2].join('');
		this.projecterFld = {
			xtype : 'xlovfield',
			name : 'projecter_id',
			fieldLabel : divo.required+'施工(消防专业承包)单位',
			allowBlank : true,
			multiSelect : false,
			lovTitle : '请选择',
			lovHeight : 350,
			lovWidth : 550,
			minItem : 1,
			maxItem : 1,
			width : 300,
			valueField : 'id',	
			displayField : lovDisplay,
			textarea : false,
			isReadOnly : this.readOnly,  //不能使用 readOnly 
			view : new panel.xf.ProjecterGridPanel({
				isLookup : true
			})
		}
		
		var items = []
		items.push({
				fieldLabel : "小标题",
				readOnly : this.readOnly,
				name : "name"
		})
		if (this.tryOutOnly) {
			//试用期间
			if (this.projecterInputType==1) {
				items.push({
					fieldLabel : divo.required+"施工(消防专业承包)单位",
					readOnly : this.readOnly,
					name : "projecter_name_raw",
					width : 400
				})
				items.push({
					fieldLabel : divo.required+"联系电话",
					readOnly : this.readOnly,
					name : "projecter_tele",
					width : 400
				})
				items.push({
					xtype : "combo",
					fieldLabel : divo.required+"工程资质等级",
					hiddenName : "projecter_project_grade",
					plugins: [new Ext.ux.FieldReadOnlyPlugin()],
					width : 150,
					store : new divo.data.SimpleListStore({
						id : "value",
						fields : [{
							name : "value"
						}, {
							name : "display"
						}],
						data : [{
							value : "一级",
							display : "一级"
						}, {
							value : "二级",
							display : "二级"
						}, {
							value : "三级",
							display : "三级"
						}, {
							value : "临时",
							display : "临时"
						}]
						}),
					valueField : "value",
					displayField : "display",
					typeAhead : false,
					mode : "local",
					triggerAction : "all",
					emptyText : "请选择",
					selectOnFocus : true,
					anchor : "100%",
					hidden : false,
					editable : false
				})
				items.push({
					fieldLabel : divo.required+"资质证书编号",
					readOnly : this.readOnly,
					name : "projecter_qualification_number",
					width : 400
				})
			}
			if (this.projecterInputType==2) {
				items.push({
					fieldLabel : divo.required+"施工(消防专业承包)单位",
					readOnly : this.readOnly,
					name : "projecter_name_raw",
					width : 400
				})
			}
		} else {
			//正式使用时
			if (this.projecterInputType==1) {
				items.push(this.projecterFld)
			}
			if (this.projecterInputType==2) {
				items.push({
					fieldLabel : divo.required+"施工(消防专业承包)单位",
					readOnly : this.readOnly,
					name : "projecter_name_raw",
					width : 400
				})
			}
		}
		items.push({
				fieldLabel : divo.required,
				labelSeparator : "",
				xtype : 'formHtml',
				hidden : this.readOnly,
				value : '为了保证报告打印质量，请使用回车换行。'
		})
		items.push({
				xtype : 'textarea',
				fieldLabel : "系统概述",
				name : "descrip",
				readOnly : this.readOnly,
				grow : true,
				width : 550
		})
		Ext.apply(this, {
			labelWidth : 100,
			defaultType : "textfield",
			labelAlign : "right",
			autoScroll : true,
			bodyStyle : "padding:10px",
			layout : 'autotableform',
			items : items	
		})
		form.xf.CheckReportHomeForm.superclass.initComponent.call(this)
	},
	//重写
	loadItem : function() {
		Ext.Ajax.request({
			scope : this,
			url : this.url,
			method : 'GET',
			success : function(response, options) {
				var resp = Ext.decode(response.responseText)
				if (resp.success) {
					this.getForm().setValues(resp.data)
					
					var fld = this.getForm().findField("projecter_id")
					if (fld)
						fld.setNameValue(resp.data.projecter_name,resp.data.projecter_id)
				}
			},
			failure : function(response, options) {
				this.alert(response.responseText);
			}
		})
	}

})

Ext.reg("form.xf.CheckReportHomeForm", form.xf.CheckReportHomeForm)
// EOP

;/**
 * 系统评述
 */
form.xf.CheckReportNoteForm = Ext.extend(divo.form.AutoSaveForm, {
	checkReportId : null,
	systemId : null,
	initFocusFldName : 'check_note',
	readOnly : false,
	initComponent : function() {
		this.url = "/xf/checkreports/"+this.checkReportId+"/system/"+this.systemId
		
		Ext.apply(this, {
			labelWidth : 100,
			defaultType : "textfield",
			labelAlign : "right",
			autoScroll : true,
			bodyStyle : "padding:10px",
			layout : 'autotableform',
			items : [{
				fieldLabel : divo.required,
				labelSeparator : "",
				xtype : 'formHtml',
				hidden : this.readOnly,
				value : '为了保证报告打印质量，请使用回车换行。'
			},{
				xtype : 'textarea',
				fieldLabel : '系统评述',
				name : "check_note",
				readOnly : this.readOnly,
				grow : true,
				width : 550
			},{
				xtype : 'checkbox',
				boxLabel : '与系统概述合并打印',
				labelSeparator: '',
				name : "descrip_note_merged",
				hidden : this.readOnly,
				listeners : {
					check : this.onMergedChecked.createDelegate(this),
					scope : this
				} //TODO 不能与check_note一起提交？
			}]	
		})
		form.xf.CheckReportNoteForm.superclass.initComponent.call(this)
	},
	onMergedChecked : function(o, checked) {
		Ext.Ajax.request({
			scope : this,
			url : this.url,
			async : false,
			method : 'PUT',
			jsonData : {descrip_note_merged:checked},
			failure : function(response, options) {
				this.alert(response.responseText)
			}
		})
	}

})

Ext.reg("form.xf.CheckReportNoteForm", form.xf.CheckReportNoteForm)
// EOP

;/**
 * 检测报告总表 - 被检测的建筑物
 */
form.xf.CheckReportBuildingAddOrEditForm = Ext.extend(divo.form.AddOrEditForm, {
	initFocusFldName : 'name',
	checkReportId : null,
	buildingRecordId : null,
	initComponent : function() {
		this.url = "/xf/checkreports/"+this.checkReportId+"/buildings"
		Ext.apply(this, {
			labelWidth : 150,
			defaultType : "textfield",
			labelAlign : "right",
			autoScroll : true,
			bodyStyle : "padding:10px",
			layout : 'autotableform',
			items : [{
				fieldLabel : divo.required + "名称",
				name : "name",
				width : 300
			},{
				xtype : 'numberfield',
				fieldLabel : '层数',
				readOnly : this.readOnly,
				name : 'floor_count',
				decimalPrecision : 0,
				allowNegative : false,
				width : 150,
				maxLength : 5
			},{
				xtype : 'numberfield',
				fieldLabel : "高度(米)",
				readOnly : this.readOnly,
				name : "height",
				decimalPrecision : 2,
				allowNegative : false,
				width : 150,
				maxLength : 6
			},{
				xtype : 'numberfield',
				fieldLabel : "面积(平方米)",
				readOnly : this.readOnly,
				name : "building_area",
				decimalPrecision : 2,
				allowNegative : false,
				width : 150,
				maxLength : 12
			}]
		})
		form.xf.CheckReportBuildingAddOrEditForm.superclass.initComponent.call(this);
	},
	//重写
	loadItem : function() {
		Ext.Ajax.request({
			scope : this,
			url : this.url + "/"+this.buildingRecordId,
			method : 'GET',
			success : function(response, options) {
				var resp = Ext.decode(response.responseText);
				this.getForm().setValues(resp.data)
			},
			failure : function(response, options) {
				this.alert(response.responseText);
			}
		})
	},
	// public
	save : function(callbackOnSuccess) {
		var item = this.getForm().getObjectValues()
		Ext.Ajax.request({
			scope : this,
			url : this.url + (this.adding ? "" : "/" + this.buildingRecordId),
			waitMsg : "正在提交...",
			method : (this.adding ? 'POST' : 'PUT'),
			jsonData : item,
			success : function(response, options) {
				var resp = Ext.decode(response.responseText)
				if (!resp.success) {
					this.getForm().markInvalid(resp.errors)
				} else {
					callbackOnSuccess(resp.id)
				}
			},
			failure : function(response, options) {
				this.alert(response.responseText)
			}
		})
	}
})

Ext.reg("form.xf.CheckReportBuildingAddOrEditForm", form.xf.CheckReportBuildingAddOrEditForm)
// EOP

;/**
 * 设备清单中的产品添加或修改表单
 */
form.xf.CheckReportProductAddOrEditForm = Ext.extend(divo.form.AddOrEditForm, {
	checkReportId : null,
	checkReportType : null,
	productRecordId : null,
	tryOutOnly : null,
	customLabelWidth : 150,
	readOnly : false,
	systemId : null, 
	initFocusFldName :null,
	initComponent : function() {
		this.url = "/xf/checkreports/"+this.checkReportId+"/system/"+this.systemId
		this.initFocusFldName = this.tryOutOnly? 'product_name':'product_id'
		
		var lovDisplay = [divo.t1 + '{name}' + divo.t2].join('');
		this.productFld = {
			xtype : 'xlovfield',
			name : 'product_id',
			fieldLabel : '产品',
			allowBlank : true,
			multiSelect : false,
			lovTitle : '请选择',
			lovHeight : 350,
			lovWidth : 550,
			minItem : 1,
			maxItem : 1,
			width : 300,
			valueField : 'id',
			displayField : lovDisplay,
			textarea : false,
			view : new panel.xf.ProductGridPanel({
				isLookup : true
			})
		}
		this.deviceFld = {
				xtype : 'combo',
				fieldLabel : '设备',
				name : 'device_code',
				hiddenName : 'device_code',
				emptyText : '请选择',
				mode : 'remote',
				editable : false,
				triggerAction : 'all',
				forceSelection : true,
				valueField : 'device_code',
				displayField : 'device_name',
				store : new Ext.data.Store({
					id : 'id',
					proxy : new Ext.data.HttpProxy({
						url : this.url+"/devices",
						method : 'GET'
					}),
					reader : new Ext.data.JsonReader({
						totalProperty : 'totalCount',
						root : 'rows',
						id : 'device_code'
						}, [{
							name : 'device_code'
						},{
							name : 'device_name'
						}]),
					autoLoad : true
				})		
			}
		this.amountFld = {
					xtype : 'numberfield',
					fieldLabel : "数量",
					name : "amount",
					decimalPrecision : 0,
					allowNegative : false,
					width : 50,
					maxLength : 5
			}	
		if (this.tryOutOnly) {
			//试用期间
			var catReader = new Ext.data.JsonReader({
				totalProperty : 'totalCount',
				root : 'rows',
				id : 'id'
			}, [{
				name : 'tree_code'
			},{
				name : 'name'
			}])

			var cat1Store = new Ext.data.Store({
				proxy : new Ext.data.HttpProxy({
					url : '/xf/productcats/level1',
					method : 'GET'
				}),
				reader : catReader,
				autoLoad : true
			})
			if (!this.adding)
				cat1Store.on("load", function() {
					 this.afterCat1ComboLoad()
				}, this, true)
				
			var cat2Store = new Ext.data.Store({
				proxy : new Ext.data.HttpProxy({
					method : 'GET'
				}),
				reader : catReader,
				autoLoad : false
			})
			cat2Store.on("load", function() {
			    this.afterCat2ComboLoad()
		    }, this, true)
			
			var items = []
			if (this.checkReportType==1)
				items.push(this.deviceFld)
				
			var item_products = [{
				fieldLabel : divo.required+"产品名称",
				name : "product_name",
				width : 300
			}, {
				fieldLabel : divo.required+"产品型号",
				name : "product_spec",
				width : 300
			}, new Ext.form.ComboBox({
				name : 'product_cat_code_1',
				fieldLabel : '一级分类',
				displayField : 'name',
				valueField : 'tree_code',
				hiddenName : 'product_cat_code_1',
				id : this.myId('cat1'),
				store : cat1Store,
				triggerAction : 'all',
				mode : 'local',
				editable : false,
				listeners : {
					select : {
						scope : this,
						fn : function(combo, value) {
							var cat2Combo = Ext.getCmp(this.myId('cat2'))
							cat2Combo.setValue('')
							cat2Combo.setDisabled(false)
							cat2Combo.store.proxy.conn.url = "/xf/productcats/childs/"+combo.getValue()
							cat2Combo.store.reload()
						}
					}
				}
			}), new Ext.form.ComboBox({
				name : 'product_cat_code_1',
				fieldLabel : '二级分类',
				displayField : 'name',
				valueField : 'tree_code',
				hiddenName : 'product_cat_code_2',
				id : this.myId('cat2'),
				disabled : this.adding,
				editable : false,
				store : cat2Store,
				triggerAction : 'all',
				mode : 'local',
				autoHeight : true
			}),{
				fieldLabel : "生产厂家",
				name : 'product_producer_name',
				width : 300
			}, {
				fieldLabel : "商标",
				name : 'product_brand',
				width : 300
			}, {
				xtype : "radiogroup",
				width : 240,
				fieldLabel : "认证类别",
				items: [
                    {boxLabel: '3C认证', name: 'product_auth_type',inputValue: '3C认证', checked: true},
                    {boxLabel: '型式认证', name: 'product_auth_type',inputValue: '型式认证'},
                    {boxLabel: '型式检验', name: 'product_auth_type',inputValue: '型式检验'}
                ]
			},{
				fieldLabel : "认证编号",
				name : 'product_auth_code',
				maxLength : 20,
				width : 180
			}, {
				xtype : 'datefield',
				fieldLabel : "认证有效期(截止日期)",
				name : 'product_end_date',
				format : 'Y.m.d',
				width : 100
			},this.amountFld,{
				fieldLabel : "单位",
				name : "product_unit_name",
				width : 50
			}]
			
			items = items.concat(item_products)
			
			if (this.checkReportType==2) {
				items.push({
					xtype : 'numberfield',
					fieldLabel : '厚度(mm)',
					readOnly : this.readOnly,
					name : 'product_thick',
					decimalPrecision : 0,
					allowNegative : false,
					width : 50,
					maxLength : 5
				})
				items.push({
					xtype : 'numberfield',
					fieldLabel : '耐火极限(h)',
					readOnly : this.readOnly,
					name : 'product_fire_endure_hour',
					decimalPrecision : 0,
					allowNegative : false,
					width : 50,
					maxLength : 5
				})
			}
		} else {
			//正式用
			var items = [this.deviceFld,this.productFld,this.amountFld]
		}
		Ext.apply(this, {
			labelWidth : this.customLabelWidth,
			defaultType : "textfield",
			labelAlign : "right",
			autoScroll : true,
			bodyStyle : "padding:10px",
			//layout : 'autotableform',
			items : items 
		})

		form.xf.CheckReportProductAddOrEditForm.superclass.initComponent.call(this)
	},
	//重写
	loadItem : function() {
		Ext.Ajax.request({
			scope : this,
			url : this.url+"/products/"+this.productRecordId,
			method : 'GET',
			success : function(response, options) {
				var resp = Ext.decode(response.responseText);
				this.getForm().setValues(resp.data)

				var fld = this.getForm().findField("product_id")
				if (fld)
					fld.setNameValue(resp.data.product_name,resp.data.product_id)
					
				this.cat_code1 = resp.data.product_cat_code_1
				this.cat_code2 = resp.data.product_cat_code_2
				
				var cat2Combo = Ext.getCmp(this.myId('cat2'))
				cat2Combo.store.proxy.conn.url = "/xf/productcats/childs/"+resp.data.product_cat_code_1
				cat2Combo.store.reload()
			},
			failure : function(response, options) {
				this.alert(response.responseText);
			}
		})
	},
	// public
	save : function(callbackOnSuccess) {
		var item = this.getForm().getObjectValues()
		if (this.checkReportType==2) {
			item.device_code = '01'
		}
		var cat1Combo = Ext.getCmp(this.myId('cat1'))
		var cat2Combo = Ext.getCmp(this.myId('cat2'))
	    item.product_cat_name_1 = cat1Combo.el.dom.value
	    item.product_cat_name_2 = cat2Combo.el.dom.value
		Ext.Ajax.request({
			scope : this,
			url : this.url+"/products" + (this.adding ? "" : "/" + this.productRecordId),
			method : (this.adding ? 'POST' : 'PUT'),
			jsonData : item,
			success : function(response, options) {
				var resp = Ext.decode(response.responseText)
				if (!resp.success) {
					this.getForm().markInvalid(resp.errors)
				} else {
					callbackOnSuccess(resp.id)
				}
			},
			failure : function(response, options) {
				this.alert(response.responseText)
			}
		})
	},
	afterCat1ComboLoad : function() {
		if (!this.cat_code1) return
		
		var cat1Combo = Ext.getCmp(this.myId('cat1'))
		var i = cat1Combo.store.find("tree_code",this.cat_code1)
		var r = cat1Combo.store.getAt(i)
		cat1Combo.setValue(r.data.name)
	},		
	afterCat2ComboLoad : function() {
		var cat2Combo = Ext.getCmp(this.myId('cat2'))
		if (this.adding) {
            if (cat2Combo.store.getCount()==1) {
				var r = cat2Combo.store.getAt(0)
				cat2Combo.setValue(r.data.name)
			}
			return
		}
		var i = cat2Combo.store.find("tree_code",this.cat_code2)
		var r = cat2Combo.store.getAt(i)
		cat2Combo.setValue(r.data.name)
	}

})

Ext.reg("form.xf.CheckReportProductAddOrEditForm", form.xf.CheckReportProductAddOrEditForm)
// EOP
;/**
 * 添加新系统表单
 */
form.xf.CheckReportSystemAddForm = Ext.extend(divo.form.AddOrEditForm, {
	checkReportId : null,
	checkReportType : null,
	customLabelWidth : 100,
	initFocusFldName : 'product_id',
	initComponent : function() {
		this.systemFld = {
				xtype : 'combo',
				fieldLabel : '系统',
				name : 'code',
				hiddenName : 'code',
				emptyText : '',
				mode : 'remote',
				editable : false,
				triggerAction : 'all',
				forceSelection : true,
				valueField : 'code',
				displayField : 'name',
				store : new Ext.data.Store({
					id : 'id',
					proxy : new Ext.data.HttpProxy({
						url : "/xf/checkreports/types/"+this.checkReportType+"/system",
						method : 'GET'
					}),
					reader : new Ext.data.JsonReader({
						totalProperty : 'totalCount',
						root : 'rows',
						id : 'id'
						}, [{
							name : 'code'
						},{
							name : 'name'
						}]),
					autoLoad : true
				})		
			}
		Ext.apply(this, {
			labelWidth : this.customLabelWidth,
			subLabelWidth : 20,
			defaultType : "textfield",
			labelAlign : "right",
			autoScroll : true,
			bodyStyle : "padding:10px",
			layout : 'autotableform',
			items : [this.systemFld,{
				fieldLabel : "小标题",
				name : "name"
			}] 
		})

		form.xf.CheckReportSystemAddForm.superclass.initComponent.call(this)
	},
	// public
	save : function(callbackOnSuccess) {
		var item = this.getForm().getObjectValues()
		Ext.Ajax.request({
			scope : this,
			url : "/xf/checkreports/"+this.checkReportId+"/system",
			method : 'POST',
			jsonData : item,
			success : function(response, options) {
				var resp = Ext.decode(response.responseText)
				if (!resp.success) {
					this.getForm().markInvalid(resp.errors)
				} else {
					callbackOnSuccess(resp.id)
				}
			},
			failure : function(response, options) {
				this.alert(response.responseText)
			}
		})
	}

})

Ext.reg("form.xf.CheckReportSystemAddForm", form.xf.CheckReportSystemAddForm)
// EOP
;/**
 * 带有HTML表格CRUD功能的表单类
 */
form.xf.CheckReportHtmlTableForm = Ext.extend(divo.form.AutoSaveForm, {
	checkReportId : null,
	systemId : null,
	customLabelWidth : 200,
	readOnly : false,
	c1 : '<tr height="20"><td width="197" align="right">',
	c2 : '<td width="338" align="center">',
	c3 : '<td width="135" align="center">',
	tableStart : '<table class="divo-table" align="center" border="1" cellpadding="0" cellspacing="0" width="670"><tbody>',
	tableEnd : '</tbody></table>',
	initComponent : function() {
		this.url = "/xf/checkreports/" + this.checkReportId + "/system/"+this.systemId
		form.xf.CheckReportHtmlTableForm.superclass.initComponent.call(this)
	},
	getRecordData : function(v) {
		if (!v) return "--"
		return v.replace(/\n/g, "<br/>")
	},
	getResultData : function(v) {
		return !v?'--':v
	},
	getResultRecords : function(partCode,url) {
		if (!url)
		   var url = this.url
		var data = []
		Ext.Ajax.request({
			scope : this,
			url : url+"/part"+partCode,
			async : false,
			method : 'GET',
			success : function(response, options) {
				data = Ext.decode(response.responseText)
			}
		})
		return data
	},
	getResultOperationStr : function(id,partCode) {
		if (this.readOnly) return ""
        return '<a id="'+this.myId(partCode+'-u-'+id)+'" href="#">'+
		        '<span style="TEXT-DECORATION: underline;cursor:hand;">修改</span></a>&nbsp;&nbsp;|&nbsp;&nbsp;'+
				'<a id="'+this.myId(partCode+'-d-'+id)+'" href="#">'+
		        '<span style="TEXT-DECORATION: underline;cursor:hand;">删除</span></a>'
	},
	//重写
	initForm : function() {
		form.xf.CheckReportHtmlTableForm.superclass.initForm.call(this)
		
		this.el.on({
			click : {
				stopEvent : false,
				delegate : 'a',
				scope : this,
				fn : function(e, target) {
					var ss = target.id.split("-")
					if (ss.length<3) return
					if (ss[ss.length-2]=='u') {
						eval("this.showEditWin"+ss[ss.length-3]+"("+ss[ss.length-1]+")")
					}
					if (ss[ss.length-2]=='d') {
						this.deleteResultRecord(ss[ss.length-3],ss[ss.length-1])
					}
				}
			}
		}) //捕获修改和删除链接信息
	},
	deleteResultRecord : function(partCode,id) {
		var ok = true
		Ext.Ajax.request({
			scope : this,
			url : this.url+"/part"+partCode+"/"+id,
			async : false,
			method : 'DELETE',
			success : function(response, options) {
				var resp = Ext.decode(response.responseText)
				if (!resp.success) {
					ok = false
				    this.say(resp.errors.reason)
				}     
			},
			failure : function(response, options) {
				this.alert(response.responseText)
				ok = false
			}
		})
		if (ok) {
			eval("this.onShowHtml(null,{partCode:'"+partCode+"'})")
		}
	},
	onShowHtml : function(subj, msg, data) {
		var partCode = msg.partCode
		var el = Ext.get(this.myId("h"+partCode))
		el.dom.innerHTML = eval("this.show"+partCode+"()")
	}

})
// EOP

;/**
 * 检测记录基类(用于检测结果附表标签页）
 */
form.xf.CheckReportResultBaseForm = Ext.extend(form.xf.CheckReportHtmlTableForm, {
	initComponent : function() {
		Ext.apply(this, {
			labelWidth : this.customLabelWidth,
			subLabelWidth : 20,
			defaultType : "textfield",
			labelAlign : "right",
			autoScroll : true,
			bodyStyle : "padding:10px",
			layout : 'autotableform',
			items : this.getRecordItems() 
		})
		
		form.xf.CheckReportResultBaseForm.superclass.initComponent.call(this)
	},
	//子类需要重写
	getRecordItems : function() {
		return []
	}
})
// EOP

;/**
 * 表格记录新建或修改基类
 */
form.xf.CheckReportResultBaseAddOrEditForm = Ext.extend(divo.form.AddOrEditForm, {
	initFocusFldName : 'name',
	checkReportId : null,
	systemId : null,
	resultRecordId : null,
	partCode : null,
	customLabelWidth : null,
	initComponent : function() {
		this.url = "/xf/checkreports/"+this.checkReportId+"/system/"+
					this.systemId+"/part"+this.partCode
		Ext.apply(this, {
			labelWidth : this.customLabelWidth || 80,
			defaultType : "textfield",
			labelAlign : "right",
			autoScroll : true,
			bodyStyle : "padding:10px",
			layout : 'autotableform',
			items : this.getRecordItems() 
		})
		form.xf.CheckReportResultBaseAddOrEditForm.superclass.initComponent.call(this);
	},
	//子类需要重写
	getRecordItems : function() {
		return []
	},
	//重写
	loadItem : function() {
		Ext.Ajax.request({
			scope : this,
			url : this.url + "/"+this.resultRecordId,
			method : 'GET',
			success : function(response, options) {
				var resp = Ext.decode(response.responseText);
				this.getForm().setValues(resp.data)
			},
			failure : function(response, options) {
				this.alert(response.responseText);
			}
		})
	},
	// public
	save : function(callbackOnSuccess) {
		var item = this.getForm().getObjectValues()
		Ext.Ajax.request({
			scope : this,
			url : this.url + (this.adding ? "" : "/" + this.resultRecordId),
			waitMsg : "正在提交...",
			method : (this.adding ? 'POST' : 'PUT'),
			jsonData : item,
			success : function(response, options) {
				var resp = Ext.decode(response.responseText)
				if (!resp.success) {
					this.getForm().markInvalid(resp.errors)
				} else {
					callbackOnSuccess(resp.id)
				}
			},
			failure : function(response, options) {
				this.alert(response.responseText)
			}
		})
	}
})

Ext.reg("form.xf.CheckReportResultBaseAddOrEditForm", form.xf.CheckReportResultBaseAddOrEditForm)
// EOP

;/**
 * 机械防排烟系统 ：检测记录表
 */
form.xf.CheckReportResult102Form = Ext.extend(form.xf.CheckReportResultBaseForm, {
	initFocusFldName : 'note_05',
	readOnly : false,
	initComponent : function() {
		this.subscribe("window.xf.CheckReportResult123Changed",this.onShowHtml,this)
		this.subscribe("window.xf.CheckReportResult124Changed",this.onShowHtml,this)
		this.subscribe("window.xf.CheckReportResult125Changed",this.onShowHtml,this)
		this.on('beforedestroy',function() {
		      this.unsubscribe()
		},this)
		
		form.xf.CheckReportResult102Form.superclass.initComponent.call(this)
	},
	getRecordItems : function() {
		return [{	
			fieldLabel : "1、排烟系统参数检测结果",
			text : '添加...',
			xtype : this.readOnly?'formHtml':'formBtn',
			handler : this.showAddWin123,
			scope : this
		},{	
			hideLabel : true,
			xtype : 'formHtml',
			value : '<div id="'+this.myId("h123")+'">'+this.show123()+'</div>'
		}, {
			xtype : 'textarea',
			fieldLabel : "备注",
			name : 'note_05',
			readOnly : this.readOnly,
			width : 550,
			height : 50
		}, {
			fieldLabel : "2、补风系统参数检测结果",
			text : '添加...',
			xtype : this.readOnly?'formHtml':'formBtn',
			handler : this.showAddWin124,
			scope : this
		},{	
			hideLabel : true,
			xtype : 'formHtml',
			value : '<div id="'+this.myId("h124")+'">'+this.show124()+'</div>'
		}, {
			xtype : 'textarea',
			fieldLabel : "备注",
			name : 'note_06',
			readOnly : this.readOnly,
			width : 550,
			height : 50
		}, {
			fieldLabel : "3、加压送风系统参数检测结果",
			text : '添加...',
			xtype : this.readOnly?'formHtml':'formBtn',
			handler : this.showAddWin125,
			scope : this
		},{	
			hideLabel : true,
			xtype : 'formHtml',
			value : '<div id="'+this.myId("h125")+'">'+this.show125()+'</div>'
		}, {
			xtype : 'textarea',
			fieldLabel : "备注",
			name : 'note_07',
			readOnly : this.readOnly,
			width : 550,
			height : 50
		}]
	},
	show123 : function() {
		var partCode = "123"
		    
		var url = "/xf/checkreports/" + this.checkReportId + "/system/"+this.systemId
		var data = this.getResultRecords(partCode,url)
		if (data.length==0)  {
			return ""
		}
		var h = []
		h.push('<table class="divo-table" align="center" border="1" cellpadding="0" cellspacing="0" width="830"><tbody>')
       	h.push('<tr height="20"><td width="18" align="right">序<br/>号</td>')
       	h.push('<td width="120" align="center">测试部位<br/>(防烟分区)</td>')
       	h.push('<td width="120" align="center">实测排烟量<br/>(m3/h)</td>')
       	h.push('<td width="120" align="center">实测换气次数<br/>(次/h)</td>')
       	h.push('<td width="120" align="center">规范要求排烟量<br/>(m3/h)</td>')
       	h.push('<td width="120" align="center">设计排烟量<br/>(m3/h)</td>')
       	h.push('<td width="120" align="center">检测结果</td>')
       	h.push('<td width="120" align="center">备注</td>')
       	if (this.readOnly)
       		h.push('</tr>')
       	else	
       		h.push('<td width="80" align="center">操作</td></tr>')
        for (var i = 0; i < data.length; i++) {
        	v = data[i]
	       	h.push('<tr height="20"><td width="18" align="right">'+v.order_number+'</td>')
	       	h.push('<td width="120" align="center">'+this.getRecordData(v.name)+'</td>')
	       	h.push('<td width="120" align="center">'+this.getRecordData(v.r1)+'</td>')
	       	h.push('<td width="120" align="center">'+this.getRecordData(v.r2)+'</td>')
	       	h.push('<td width="120" align="center">'+this.getRecordData(v.r3)+'</td>')
	       	h.push('<td width="120" align="center">'+this.getRecordData(v.r4)+'</td>')
	       	h.push('<td width="120" align="center">'+this.getRecordData(v.r5)+'</td>')
	       	h.push('<td width="120" align="center">'+this.getRecordData(v.r6)+'</td>')
	       	if (this.readOnly)
		       	h.push('</tr>')
		    else   	
		       	h.push('<td width="80" align="center">'+this.getResultOperationStr(v.id,partCode)+'</td></tr>')
        }   
        h.push(this.tableEnd)
        return h.join("")   
	},
	showAddWin123 : function() {
		var win = new window.xf.CheckReportResultAddOrEditWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			winTitle : '添加排烟系统参数检测结果',
			partCode : '123',
			customWidth : 450,
			adding : true
		})
		win.show()
	},
	showEditWin123 : function(id) {
		var win = new window.xf.CheckReportResultAddOrEditWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			winTitle : '修改排烟系统参数检测结果',
			partCode : '123',
			adding : false,
			customWidth : 450,
			resultRecordId : id
		})
		win.show()
	},
	show124 : function() {
		var partCode = "124"
		    
		var url = "/xf/checkreports/" + this.checkReportId + "/system/"+this.systemId
		var data = this.getResultRecords(partCode,url)
		if (data.length==0)  {
			return ""
		}
		var h = []
		h.push('<table class="divo-table" align="center" border="1" cellpadding="0" cellspacing="0" width="830"><tbody>')
       	h.push('<tr height="20"><td width="18" align="right">序<br/>号</td>')
       	h.push('<td width="120" align="center">测试部位<br/>(防烟分区)</td>')
       	h.push('<td width="120" align="center">实测补风量<br/>(m3/h)</td>')
       	h.push('<td width="120" align="center">设计补风量<br/>(m3/h)</td>')
       	h.push('<td width="120" align="center">检测结果</td>')
       	h.push('<td width="120" align="center">备注</td>')
       	if (this.readOnly)
       		h.push('</tr>')
       	else	
       		h.push('<td width="80" align="center">操作</td></tr>')
        for (var i = 0; i < data.length; i++) {
        	v = data[i]
	       	h.push('<tr height="20"><td width="18" align="right">'+v.order_number+'</td>')
	       	h.push('<td width="120" align="center">'+this.getRecordData(v.name)+'</td>')
	       	h.push('<td width="120" align="center">'+this.getRecordData(v.r1)+'</td>')
	       	h.push('<td width="120" align="center">'+this.getRecordData(v.r2)+'</td>')
	       	h.push('<td width="120" align="center">'+this.getRecordData(v.r3)+'</td>')
	       	h.push('<td width="120" align="center">'+this.getRecordData(v.r4)+'</td>')
	       	if (this.readOnly)
		       	h.push('</tr>')
		    else   	
		       	h.push('<td width="80" align="center">'+this.getResultOperationStr(v.id,partCode)+'</td></tr>')
        }   
        h.push(this.tableEnd)
        return h.join("")   
	},
	showAddWin124 : function() {
		var win = new window.xf.CheckReportResultAddOrEditWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			winTitle : '添加补风系统参数检测结果',
			partCode : '124',
			customWidth : 450,
			adding : true
		})
		win.show()
	},
	showEditWin124 : function(id) {
		var win = new window.xf.CheckReportResultAddOrEditWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			winTitle : '修改补风系统参数检测结果',
			partCode : '124',
			adding : false,
			customWidth : 450,
			resultRecordId : id
		})
		win.show()
	},
	show125 : function() {
		var partCode = "125"
		    
		var url = "/xf/checkreports/" + this.checkReportId + "/system/"+this.systemId
		var data = this.getResultRecords(partCode,url)
		if (data.length==0)  {
			return ""
		}
		var h = []
		h.push('<table class="divo-table" align="center" border="1" cellpadding="0" cellspacing="0" width="830"><tbody>')
       	h.push('<tr height="20"><td width="18" align="right" rowspan="2">序号</td>')
       	h.push('<td width="120" align="center" rowspan="2">测试部位</td>')
       	h.push('<td width="196" align="center" colspan="2">风压(Pa)</td>')
       	h.push('<td width="208" align="center" colspan="2">平均风速(m/s)</td>')
       	h.push('<td width="104" align="center" rowspan="2">检测结果</td>')
       	h.push('<td width="104" align="center" rowspan="2">备注</td>')
       	if (this.readOnly)
       		h.push('</tr>')
       	else	
       		h.push('<td width="80" align="center" rowspan="2">操作</td></tr>')
       	//第2行	
       	h.push('<tr height="20">')
       	h.push('<td width="76" align="center">前室</td>')
       	h.push('<td width="120" align="center">楼梯间</td>')
       	h.push('<td width="104" align="center">前室→走道</td>')
       	h.push('<td width="104" align="center">楼梯间→前室</td></tr>')
        for (var i = 0; i < data.length; i++) {
        	v = data[i]
	       	h.push('<tr height="20"><td width="18" align="right">'+v.order_number+'</td>')
	       	h.push('<td width="120" align="center">'+this.getRecordData(v.name)+'</td>')
	       	h.push('<td width="76" align="center">'+this.getRecordData(v.r1)+'</td>')
	       	h.push('<td width="120" align="center">'+this.getRecordData(v.r2)+'</td>')
	       	h.push('<td width="104" align="center">'+this.getRecordData(v.r3)+'</td>')
	       	h.push('<td width="104" align="center">'+this.getRecordData(v.r4)+'</td>')
	       	h.push('<td width="104" align="center">'+this.getRecordData(v.r5)+'</td>')
	       	h.push('<td width="104" align="center">'+this.getRecordData(v.r6)+'</td>')
	       	if (this.readOnly)
		       	h.push('</tr>')
		    else   	
		       	h.push('<td width="80" align="center">'+this.getResultOperationStr(v.id,partCode)+'</td></tr>')
        }   
        h.push(this.tableEnd)
        return h.join("")   
	},
	showAddWin125 : function() {
		var win = new window.xf.CheckReportResultAddOrEditWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			winTitle : '添加加压送风系统参数检测结果',
			partCode : '125',
			customWidth : 450,
			adding : true
		})
		win.show()
	},
	showEditWin125 : function(id) {
		var win = new window.xf.CheckReportResultAddOrEditWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			winTitle : '修改加压送风系统参数检测结果',
			partCode : '125',
			adding : false,
			customWidth : 450,
			resultRecordId : id
		})
		win.show()
	}

})

Ext.reg("form.xf.CheckReportResult102Form", form.xf.CheckReportResult102Form)
// EOP

;/**
 * 机械防排烟系统：正压送风系统参数表(新建或修改）
 */
form.xf.CheckReportResult121AddOrEditForm = Ext.extend(form.xf.CheckReportResultBaseAddOrEditForm, {
	getRecordItems : function() {
		return [{
				fieldLabel : divo.required,
				labelSeparator : "",
				xtype : 'formHtml',
				hidden : this.readOnly,
				value : '为了保证报告打印质量，对于多行文本，请使用回车换行。'
			},{
				xtype : 'textarea',
				fieldLabel : divo.required + "系统名称",
				name : "name",
				grow : true, growMin : 20,
				width : 90
			},{
				xtype : 'textarea',
				fieldLabel : "风机编号<br/>(位置)",
				name : "r1",
				grow : true, growMin : 20,
				width : 90
			},{
				xtype : 'textarea',
				fieldLabel : "保护区域",
				name : "r2",
				grow : true, growMin : 20,
				width : 70
			},{
				xtype : 'textarea',
				fieldLabel : "风量(m3/h)",
				grow : true, growMin : 20,
				width : 70,
				name : "r3"
			},{
				xtype : 'textarea',
				fieldLabel : "风压(Pa)",
				grow : true, growMin : 20,
				width : 70,
				name : "r4"
			},{
				xtype : 'textarea',
				fieldLabel : "功率(kw)",
				grow : true, growMin : 20,
				width : 70,
				name : "r5"
			},{
				xtype : 'textarea',
				fieldLabel : "转速(r/min)",
				grow : true, growMin : 20,
				width : 70,
				name : "r6"
			},{
				xtype : 'textarea',
				fieldLabel : "数量(台)",
				grow : true, growMin : 20,
				width : 70,
				name : "r7"
			}]
	}
})

Ext.reg("form.xf.CheckReportResult121AddOrEditForm", form.xf.CheckReportResult121AddOrEditForm)
// EOP

;/**
 * 机械防排烟系统：排烟及排烟时的补风系统参数表(新建或修改）
 */
form.xf.CheckReportResult122AddOrEditForm = Ext.extend(form.xf.CheckReportResultBaseAddOrEditForm, {
	getRecordItems : function() {
		return [{
				fieldLabel : divo.required,
				labelSeparator : "",
				xtype : 'formHtml',
				hidden : this.readOnly,
				value : '为了保证报告打印质量，对于多行文本，请使用回车换行。'
			},{
				xtype : 'textarea',
				fieldLabel : divo.required + "系统名称",
				name : "name",
				grow : true, growMin : 20,
				width : 90
			},{
				xtype : 'textarea',
				fieldLabel : "风机编号<br/>(位置)",
				name : "r1",
				grow : true, growMin : 20,
				width : 90
			},{
				xtype : 'textarea',
				fieldLabel : "保护区域",
				name : "r2",
				grow : true, growMin : 20,
				width : 70
			},{
				xtype : 'textarea',
				fieldLabel : "风量(m3/h)",
				grow : true, growMin : 20,
				width : 70,
				name : "r3"
			},{
				xtype : 'textarea',
				fieldLabel : "风压(Pa)",
				grow : true, growMin : 20,
				width : 70,
				name : "r4"
			},{
				xtype : 'textarea',
				fieldLabel : "功率(kw)",
				grow : true, growMin : 20,
				width : 70,
				name : "r5"
			},{
				xtype : 'textarea',
				fieldLabel : "转速(r/min)",
				grow : true, growMin : 20,
				width : 70,
				name : "r6"
			},{
				xtype : 'textarea',
				fieldLabel : "数量(台)",
				grow : true, growMin : 20,
				width : 70,
				name : "r7"
			}]
	}
})

Ext.reg("form.xf.CheckReportResult122AddOrEditForm", form.xf.CheckReportResult122AddOrEditForm)
// EOP

;/**
 * 机械防排烟系统：排烟系统参数检测结果(新建或修改）
 */
form.xf.CheckReportResult123AddOrEditForm = Ext.extend(form.xf.CheckReportResultBaseAddOrEditForm, {
	getRecordItems : function() {
		return [{
				fieldLabel : divo.required,
				labelSeparator : "",
				xtype : 'formHtml',
				hidden : this.readOnly,
				value : '为了保证报告打印质量，对于多行文本，请使用回车换行。'
			},{
				xtype : 'textarea',
				fieldLabel : divo.required + "测试部位(防烟分区)",
				name : "name",
				grow : true, growMin : 20,
				width : 110
			},{
				xtype : 'textarea',
				fieldLabel : "实测排烟量(m3/h)",
				grow : true, growMin : 20,
				width : 70,
				name : "r1"
			},{
				xtype : 'textarea',
				fieldLabel : "实测换气次数(次/h)",
				grow : true, growMin : 20,
				width : 70,
				name : "r2"
			},{
				xtype : 'textarea',
				fieldLabel : "规范要求排烟量(m3/h)",
				grow : true, growMin : 20,
				width : 70,
				name : "r3"
			},{
				xtype : 'textarea',
				fieldLabel : "设计排烟量(m3/h)",
				grow : true, growMin : 20,
				width : 70,
				name : "r4"
			},{
				xtype : 'textarea',
				fieldLabel : "检测结果",
				grow : true, growMin : 20,
				width : 95,
				name : "r5"
			},{
				xtype : 'textarea',
				fieldLabel : "备注",
				grow : true, growMin : 20,
				width : 95,
				name : "r6"
			}]
	}
})

Ext.reg("form.xf.CheckReportResult123AddOrEditForm", form.xf.CheckReportResult123AddOrEditForm)
// EOP

;/**
 * 机械防排烟系统：补风系统参数检测结果(新建或修改）
 */
form.xf.CheckReportResult124AddOrEditForm = Ext.extend(form.xf.CheckReportResultBaseAddOrEditForm, {
	getRecordItems : function() {
		return [{
				fieldLabel : divo.required,
				labelSeparator : "",
				xtype : 'formHtml',
				hidden : this.readOnly,
				value : '为了保证报告打印质量，对于多行文本，请使用回车换行。'
			},{
				xtype : 'textarea',
				fieldLabel : divo.required + "测试部位(防烟分区)",
				name : "name",
				grow : true, growMin : 20,
				width : 190
			},{
				xtype : 'textarea',
				fieldLabel : "实测补风量(m3/h)",
				grow : true, growMin : 20,
				width : 70,
				name : "r1"
			},{
				xtype : 'textarea',
				fieldLabel : "设计补风量(m3/h)",
				grow : true, growMin : 20,
				width : 70,
				name : "r2"
			},{
				xtype : 'textarea',
				fieldLabel : "检测结果",
				grow : true, growMin : 20,
				width : 125,
				name : "r3"
			},{
				xtype : 'textarea',
				fieldLabel : "备注",
				grow : true, growMin : 20,
				width : 125,
				name : "r4"
			}]
	}
})

Ext.reg("form.xf.CheckReportResult124AddOrEditForm", form.xf.CheckReportResult124AddOrEditForm)
// EOP

;/**
 * 机械防排烟系统：加压送风系统参数检测结果(新建或修改）
 */
form.xf.CheckReportResult125AddOrEditForm = Ext.extend(form.xf.CheckReportResultBaseAddOrEditForm, {
	getRecordItems : function() {
		return [{
				fieldLabel : divo.required,
				labelSeparator : "",
				xtype : 'formHtml',
				hidden : this.readOnly,
				value : '为了保证报告打印质量，对于多行文本，请使用回车换行。'
			},{
				xtype : 'textarea',
				fieldLabel : divo.required + "测试部位",
				grow : true, growMin : 20,
				width : 85,
				name : "name"
		    }, {
				fieldLabel : "",
				labelSeparator : "",
				xtype : 'formHtml',
				value : '风压(Pa)'
			},{
				xtype : 'textarea',
				fieldLabel : "前室",
				grow : true, growMin : 20,
				width : 70,
				name : "r1"
			},{
				xtype : 'textarea',
				fieldLabel : "楼梯间",
				grow : true, growMin : 20,
				width : 70,
				name : "r2"
		    }, {
				fieldLabel : "",
				labelSeparator : "",
				xtype : 'formHtml',
				value : '平均风速(m/s)'
			},{
				xtype : 'textarea',
				fieldLabel : "前室→走道",
				grow : true, growMin : 20,
				width : 70,
				name : "r3"
			},{
				xtype : 'textarea',
				fieldLabel : "楼梯间→前室",
				grow : true, growMin : 20,
				width : 70,
				name : "r4"
			},{
				xtype : 'textarea',
				fieldLabel : "检测结果",
				grow : true, growMin : 20,
				width : 85,
				name : "r5"
			},{
				xtype : 'textarea',
				fieldLabel : "备注",
				grow : true, growMin : 20,
				width : 85,
				name : "r6"
			}]
	}
})

Ext.reg("form.xf.CheckReportResult125AddOrEditForm", form.xf.CheckReportResult125AddOrEditForm)
// EOP

;/**
 * 室内外消火栓给水系统 ：检测记录表
 */
form.xf.CheckReportResult105Form = Ext.extend(form.xf.CheckReportResultBaseForm, {
	initFocusFldName : 'note_01',
	readOnly : false,
	initComponent : function() {
		this.subscribe("window.xf.CheckReportResult151Changed",this.onShowHtml,this)
		this.on('beforedestroy',function() {
		      this.unsubscribe()
		},this)
		
		form.xf.CheckReportResult105Form.superclass.initComponent.call(this)
	},
	getRecordItems : function() {
		return [{	
			fieldLabel : "室内消火栓系统压力测试结果",
			text : '添加...',
			xtype : this.readOnly?'formHtml':'formBtn',
			handler : this.showAddWin151,
			scope : this
		},{	
			hideLabel : true,
			xtype : 'formHtml',
			value : '<div id="'+this.myId("h151")+'">'+this.show151()+'</div>'
		}, {
			xtype : 'textarea',
			fieldLabel : "备注",
			name : 'note_01',
			readOnly : this.readOnly,
			width : 550,
			height : 50
		}]
	},
	show151 : function() {
		var partCode = "151"
		    
		var url = "/xf/checkreports/" + this.checkReportId + "/system/"+this.systemId
		var data = this.getResultRecords(partCode,url)
		if (data.length==0)  {
			return ""
		}
		var h = []
		h.push('<table class="divo-table" align="center" border="1" cellpadding="0" cellspacing="0" width="830"><tbody>')
       	h.push('<tr height="20"><td width="18" align="right">序<br/>号</td>')
       	h.push('<td width="340" align="center">楼层</td>')
       	h.push('<td width="115" align="center">数量<br/>(只)</td>')
       	h.push('<td width="115" align="center">静压<br/>(MPa)</td>')
       	h.push('<td width="115" align="center">启泵动压<br/>(MPa)</td>')
       	h.push('<td width="115" align="center">减压孔板<br/>(φmm)</td>')
       	if (this.readOnly)
       		h.push('</tr>')
       	else	
       		h.push('<td width="80" align="center">操作</td></tr>')
        for (var i = 0; i < data.length; i++) {
        	v = data[i]
	       	h.push('<tr height="20"><td width="18" align="right">'+v.order_number+'</td>')
	       	h.push('<td width="340" align="center">'+this.getRecordData(v.name)+'</td>')
	       	h.push('<td width="115" align="center">'+this.getRecordData(v.r1)+'</td>')
	       	h.push('<td width="115" align="center">'+this.getRecordData(v.r2)+'</td>')
	       	h.push('<td width="115" align="center">'+this.getRecordData(v.r3)+'</td>')
	       	h.push('<td width="115" align="center">'+this.getRecordData(v.r4)+'</td>')
	       	if (this.readOnly)
		       	h.push('</tr>')
		    else   	
		       	h.push('<td width="80" align="center">'+this.getResultOperationStr(v.id,partCode)+'</td></tr>')
        }   
        h.push(this.tableEnd)
        return h.join("")   
	},
	showAddWin151 : function() {
		var win = new window.xf.CheckReportResultAddOrEditWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			winTitle : '添加室内消火栓系统压力测试结果',
			partCode : '151',
			customWidth : 450,
			adding : true
		})
		win.show()
	},
	showEditWin151 : function(id) {
		var win = new window.xf.CheckReportResultAddOrEditWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			winTitle : '修改室内消火栓系统压力测试结果',
			partCode : '151',
			adding : false,
			customWidth : 450,
			resultRecordId : id
		})
		win.show()
	}

})

Ext.reg("form.xf.CheckReportResult105Form", form.xf.CheckReportResult105Form)
// EOP

;/**
 * 室内外消火栓给水系统：室内消火栓系统压力测试结果(新建或修改）
 */
form.xf.CheckReportResult151AddOrEditForm = Ext.extend(form.xf.CheckReportResultBaseAddOrEditForm, {
	getRecordItems : function() {
		return [{
				fieldLabel : divo.required,
				labelSeparator : "",
				xtype : 'formHtml',
				hidden : this.readOnly,
				value : '为了保证报告打印质量，对于多行文本，请使用回车换行。'
			},{
				xtype : 'textarea',
				fieldLabel : divo.required + "楼层",
				grow : true, growMin : 20,
				width : 170,
				name : "name"
			},{
				xtype : 'textarea',
				fieldLabel : "数量(只)",
				grow : true, growMin : 20,
				width : 110,
				name : "r1"
			},{
				xtype : 'textarea',
				fieldLabel : "静压(MPa)",
				grow : true, growMin : 20,
				width : 110,
				name : "r2"
			},{
				xtype : 'textarea',
				fieldLabel : "启泵动压(MPa)",
				grow : true, growMin : 20,
				width : 110,
				name : "r3"
			},{
				xtype : 'textarea',
				fieldLabel : "减压孔板(φmm)",
				grow : true, growMin : 20,
				width : 110,
				name : "r4"
			}]
	}
})

Ext.reg("form.xf.CheckReportResult151AddOrEditForm", form.xf.CheckReportResult151AddOrEditForm)
// EOP

;/**
 * 自动喷水灭火系统：检测记录表
 */
form.xf.CheckReportResult106Form = Ext.extend(form.xf.CheckReportResultBaseForm, {
	initFocusFldName : 'note_01',
	readOnly : false,
	initComponent : function() {
		this.subscribe("window.xf.CheckReportResult161Changed",this.onShowHtml,this)
		this.on('beforedestroy',function() {
		      this.unsubscribe()
		},this)
		
		form.xf.CheckReportResult106Form.superclass.initComponent.call(this)
	},
	getRecordItems : function() {
		return [{	
			fieldLabel : "喷淋泵组压力测试结果",
			text : '添加...',
			xtype : this.readOnly?'formHtml':'formBtn',
			handler : this.showAddWin161,
			scope : this
		},{	
			hideLabel : true,
			xtype : 'formHtml',
			value : '<div id="'+this.myId("h161")+'">'+this.show161()+'</div>'
		}, {
			xtype : 'textarea',
			fieldLabel : "备注",
			name : 'note_01',
			readOnly : this.readOnly,
			width : 550,
			height : 50
		}]
	},
	show161 : function() {
		var partCode = "161"
		    
		var url = "/xf/checkreports/" + this.checkReportId + "/system/"+this.systemId
		var data = this.getResultRecords(partCode,url)
		if (data.length==0)  {
			return ""
		}
		var h = []
		h.push('<table class="divo-table" align="center" border="1" cellpadding="0" cellspacing="0" width="830"><tbody>')
       	h.push('<tr height="20"><td width="18" align="right">序<br/>号</td>')
       	h.push('<td width="200" align="center">系统名称</td>')
       	h.push('<td width="170" align="center">楼层</td>')
       	h.push('<td width="150" align="center">数量<br/>(只)</td>')
       	h.push('<td width="150" align="center">静压<br/>(MPa)</td>')
       	h.push('<td width="150" align="center">启泵动压<br/>(MPa)</td>')
       	if (this.readOnly)
       		h.push('</tr>')
       	else	
       		h.push('<td width="80" align="center">操作</td></tr>')
        for (var i = 0; i < data.length; i++) {
        	v = data[i]
	       	h.push('<tr height="20"><td width="18" align="right">'+v.order_number+'</td>')
	       	h.push('<td width="200" align="center">'+this.getRecordData(v.name)+'</td>')
	       	h.push('<td width="170" align="center">'+this.getRecordData(v.r1)+'</td>')
	       	h.push('<td width="150" align="center">'+this.getRecordData(v.r2)+'</td>')
	       	h.push('<td width="150" align="center">'+this.getRecordData(v.r3)+'</td>')
	       	h.push('<td width="150" align="center">'+this.getRecordData(v.r4)+'</td>')
	       	if (this.readOnly)
		       	h.push('</tr>')
		    else   	
		       	h.push('<td width="80" align="center">'+this.getResultOperationStr(v.id,partCode)+'</td></tr>')
        }   
        h.push(this.tableEnd)
        return h.join("")   
	},
	showAddWin161 : function() {
		var win = new window.xf.CheckReportResultAddOrEditWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			winTitle : '添加喷淋泵组压力测试结果',
			partCode : '161',
			customWidth : 450,
			adding : true
		})
		win.show()
	},
	showEditWin161 : function(id) {
		var win = new window.xf.CheckReportResultAddOrEditWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			winTitle : '修改喷淋泵组压力测试结果',
			partCode : '161',
			adding : false,
			customWidth : 450,
			resultRecordId : id
		})
		win.show()
	}

})

Ext.reg("form.xf.CheckReportResult106Form", form.xf.CheckReportResult106Form)
// EOP

;/**
 * 自动喷水灭火系统：喷淋泵组压力测试结果(新建或修改）
 */
form.xf.CheckReportResult161AddOrEditForm = Ext.extend(form.xf.CheckReportResultBaseAddOrEditForm, {
	getRecordItems : function() {
		return [{
				fieldLabel : divo.required,
				labelSeparator : "",
				xtype : 'formHtml',
				hidden : this.readOnly,
				value : '为了保证报告打印质量，对于多行文本，请使用回车换行。'
			},{
				xtype : 'textarea',
				fieldLabel : divo.required + "系统名称",
				grow : true, growMin : 20,
				width : 170,
				name : "name"
			},{
				xtype : 'textarea',
				fieldLabel : "楼层",
				grow : true, growMin : 20,
				width : 120,
				name : "r1"
			},{
				xtype : 'textarea',
				fieldLabel : "数量(只)",
				grow : true, growMin : 20,
				width : 100,
				name : "r2"
			},{
				xtype : 'textarea',
				fieldLabel : "静压(MPa)",
				grow : true, growMin : 20,
				width : 100,
				name : "r3"
			},{
				xtype : 'textarea',
				fieldLabel : "启泵动压(MPa)",
				grow : true, growMin : 20,
				width : 100,
				name : "r4"
			}]
	}
})

Ext.reg("form.xf.CheckReportResult161AddOrEditForm", form.xf.CheckReportResult161AddOrEditForm)
// EOP

;/**
 * 钢结构防火喷涂施工质量检测表 : 钢结构防火喷涂涂层厚度检测结果等
 */
form.xf.CheckReportResult201Form = Ext.extend(form.xf.CheckReportResultBaseForm, {
	initComponent : function() {
		this.subscribe("window.xf.CheckReportResult211Changed",this.onShowHtml,this)
		this.subscribe("window.xf.CheckReportResult212Changed",this.onShowHtml,this)
		this.on('beforedestroy',function() {
		      this.unsubscribe()
		},this)
		
		form.xf.CheckReportResult201Form.superclass.initComponent.call(this)
	},
	getRecordItems : function() {
		return [{	
			fieldLabel : "1、钢结构防火喷涂涂层厚度<br/>检测结果",
			text : '添加...',
			xtype : this.readOnly?'formHtml':'formBtn',
			handler : this.showAddWin211,
			scope : this
		},{	
			hideLabel : true,
			xtype : 'formHtml',
			value : '<div id="'+this.myId("h211")+'">'+this.show211()+'</div>'
		}, {
			fieldLabel : "2、膨胀性钢结构防火涂料涂层<br/>膨胀倍数检测结果",
			text : '添加...',
			xtype : this.readOnly?'formHtml':'formBtn',
			handler : this.showAddWin212,
			scope : this
		},{	
			hideLabel : true,
			xtype : 'formHtml',
			value : '<div id="'+this.myId("h212")+'">'+this.show212()+'</div>'
		}]
	},
	show211 : function() {
		var partCode = "211"
		    
		var url = "/xf/checkreports/" + this.checkReportId + "/system/"+this.systemId
		var data = this.getResultRecords(partCode,url)
		if (data.length==0)  {
			return ""
		}
		var h = []
		h.push('<table class="divo-table" align="center" border="1" cellpadding="0" cellspacing="0" width="830"><tbody>')
       	h.push('<tr height="20"><td width="18" align="right">序<br/>号</td>')
       	h.push('<td width="270" align="center">钢结构构件所在部位</td>')
       	h.push('<td width="270" align="center">测试构件定位</td>')
       	h.push('<td width="140" align="center">测试点数<br/>(m3/h)</td>')
       	h.push('<td width="140" align="center">涂层平均厚度<br/>(mm)</td>')
       	if (this.readOnly)
       		h.push('</tr>')
       	else	
       		h.push('<td width="80" align="center">操作</td></tr>')
        for (var i = 0; i < data.length; i++) {
        	v = data[i]
	       	h.push('<tr height="20"><td width="18" align="right">'+v.order_number+'</td>')
	       	h.push('<td width="270" align="center">'+this.getRecordData(v.name)+'</td>')
	       	h.push('<td width="270" align="center">'+this.getRecordData(v.r1)+'</td>')
	       	h.push('<td width="140" align="center">'+this.getRecordData(v.r2)+'</td>')
	       	h.push('<td width="140" align="center">'+this.getRecordData(v.r3)+'</td>')
	       	if (this.readOnly)
		       	h.push('</tr>')
		    else   	
		       	h.push('<td width="80" align="center">'+this.getResultOperationStr(v.id,partCode)+'</td></tr>')
        }   
        h.push(this.tableEnd)
        return h.join("")   
	},
	showAddWin211 : function() {
		var win = new window.xf.CheckReportResultAddOrEditWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			winTitle : '添加钢结构防火喷涂涂层厚度检测结果',
			partCode : '211',
			customHeight : 400,
			customWidth : 500,
			adding : true
		})
		win.show()
	},
	showEditWin211 : function(id) {
		var win = new window.xf.CheckReportResultAddOrEditWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			winTitle : '修改钢结构防火喷涂涂层厚度检测结果',
			partCode : '211',
			adding : false,
			customWidth : 500,
			customHeight : 400,
			resultRecordId : id
		})
		win.show()
	},
	show212 : function() {
		var partCode = "212"
		    
		var url = "/xf/checkreports/" + this.checkReportId + "/system/"+this.systemId
		var data = this.getResultRecords(partCode,url)
		if (data.length==0)  {
			return ""
		}
		var h = []
		h.push('<table class="divo-table" align="center" border="1" cellpadding="0" cellspacing="0" width="830"><tbody>')
       	h.push('<tr height="20"><td width="18" align="right">序<br/>号</td>')
       	h.push('<td width="270" align="center">钢结构构件所在部位</td>')
       	h.push('<td width="270" align="center">测试构件定位</td>')
       	h.push('<td width="140" align="center">测试点数<br/>(m3/h)</td>')
       	h.push('<td width="140" align="center">涂层平均膨胀倍数</td>')
       	if (this.readOnly)
       		h.push('</tr>')
       	else	
       		h.push('<td width="80" align="center">操作</td></tr>')
        for (var i = 0; i < data.length; i++) {
        	v = data[i]
	       	h.push('<tr height="20"><td width="18" align="right">'+v.order_number+'</td>')
	       	h.push('<td width="270" align="center">'+this.getRecordData(v.name)+'</td>')
	       	h.push('<td width="270" align="center">'+this.getRecordData(v.r1)+'</td>')
	       	h.push('<td width="140" align="center">'+this.getRecordData(v.r2)+'</td>')
	       	h.push('<td width="140" align="center">'+this.getRecordData(v.r3)+'</td>')
	       	if (this.readOnly)
		       	h.push('</tr>')
		    else   	
		       	h.push('<td width="80" align="center">'+this.getResultOperationStr(v.id,partCode)+'</td></tr>')
        }   
        h.push(this.tableEnd)
        return h.join("")   
	},
	showAddWin212 : function() {
		var win = new window.xf.CheckReportResultAddOrEditWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			winTitle : '添加膨胀性钢结构防火涂料涂层膨胀倍数检测结果',
			partCode : '212',
			customHeight : 400,
			customWidth : 500,
			adding : true
		})
		win.show()
	},
	showEditWin212 : function(id) {
		var win = new window.xf.CheckReportResultAddOrEditWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			winTitle : '修改膨胀性钢结构防火涂料涂层膨胀倍数检测结果',
			partCode : '212',
			adding : false,
			customWidth : 500,
			customHeight : 400,
			resultRecordId : id
		})
		win.show()
	}
	
})

Ext.reg("form.xf.CheckReportResult201Form", form.xf.CheckReportResult201Form)
// EOP

;/**
 * 钢结构防火喷涂涂层厚度检测:新建或修改
 */
form.xf.CheckReportResult211AddOrEditForm = Ext.extend(form.xf.CheckReportResultBaseAddOrEditForm, {
	customLabelWidth : 150,
	getRecordItems : function() {
		return [{
				fieldLabel : divo.required,
				labelSeparator : "",
				xtype : 'formHtml',
				hidden : this.readOnly,
				value : '为了保证报告打印质量，对于多行文本，请使用回车换行。'
			},{
				xtype : 'textarea',
				fieldLabel : divo.required + "钢结构构件所在部位",
				grow : true, growMin : 20,
				name : "name",
				width : 200
			},{
				xtype : 'textarea',
				fieldLabel : "测试构件定位",
				name : "r1",
				grow : true, growMin : 20,
				width : 130
			},{
				xtype : 'textarea',
				fieldLabel : "测试点数",
				grow : true, growMin : 20,
				width : 100,
				name : "r2"
			},{
				xtype : 'textarea',
				fieldLabel : "涂层平均厚度(mm)",
				grow : true, growMin : 20,
				width : 100,
				name : "r3"
			}]
	}		
})

Ext.reg("form.xf.CheckReportResult211AddOrEditForm", form.xf.CheckReportResult211AddOrEditForm)
// EOP

;/**
 * 膨胀性钢结构防火涂料涂层膨胀倍数检测:新建或修改
 */
form.xf.CheckReportResult212AddOrEditForm = Ext.extend(form.xf.CheckReportResultBaseAddOrEditForm, {
	customLabelWidth : 150,
	getRecordItems : function() {
		return [{
				fieldLabel : divo.required,
				labelSeparator : "",
				xtype : 'formHtml',
				hidden : this.readOnly,
				value : '为了保证报告打印质量，对于多行文本，请使用回车换行。'
			},{
				xtype : 'textarea',
				fieldLabel : divo.required + "钢结构构件所在部位",
				name : "name",
				grow : true, growMin : 20,
				width : 200
			},{
				xtype : 'textarea',
				fieldLabel : "测试构件定位",
				name : "r1",
				grow : true, growMin : 20,
				width : 130
			},{
				xtype : 'textarea',
				fieldLabel : "测试点数",
				grow : true, growMin : 20,
				width : 100,
				name : "r2"
			},{
				xtype : 'textarea',
				fieldLabel : "涂层平均膨胀倍数",
				grow : true, growMin : 20,
				width : 100,
				name : "r3"
			}]
	}		
})

Ext.reg("form.xf.CheckReportResult212AddOrEditForm", form.xf.CheckReportResult212AddOrEditForm)
// EOP

;/**
 * 系统概述：机械防排烟系统专用
 */
form.xf.CheckReportHome102Form = Ext.extend(form.xf.CheckReportHtmlTableForm, {
	tryOutOnly : null,
	initFocusFldName : 'descrip',
	projecterInputType : 2, //1-必须选择 2-直接输入名称 3-无施工单位
	initComponent : function() {
		var lovDisplay = [divo.t1 + '{name}' + divo.t2].join('');
		this.projecterFld = {
			xtype : 'xlovfield',
			name : 'projecter_id',
			fieldLabel : divo.required+'施工(消防专业承包)单位',
			allowBlank : true,
			multiSelect : false,
			lovTitle : '请选择',
			lovHeight : 350,
			lovWidth : 580,
			minItem : 1,
			maxItem : 1,
			width : 300,
			valueField : 'id',	
			displayField : lovDisplay,
			textarea : false,
			isReadOnly : this.readOnly,  //不能使用 readOnly 
			view : new panel.xf.ProjecterGridPanel({
				isLookup : true
			})
		}
		
		var items = []
		items.push({
				fieldLabel : "小标题",
				readOnly : this.readOnly,
				name : "name"
		})
		if (this.tryOutOnly) {
			//试用期间
			if (this.projecterInputType==1) {
				items.push({
					fieldLabel : divo.required+"施工(消防专业承包)单位",
					readOnly : this.readOnly,
					name : "projecter_name_raw",
					width : 400
				})
				items.push({
					fieldLabel : divo.required+"联系电话",
					readOnly : this.readOnly,
					name : "projecter_tele",
					width : 400
				})
				items.push({
					xtype : "combo",
					fieldLabel : divo.required+"工程资质等级",
					hiddenName : "projecter_project_grade",
					plugins: [new Ext.ux.FieldReadOnlyPlugin()],
					width : 150,
					store : new divo.data.SimpleListStore({
						id : "value",
						fields : [{
							name : "value"
						}, {
							name : "display"
						}],
						data : [{
							value : "一级",
							display : "一级"
						}, {
							value : "二级",
							display : "二级"
						}, {
							value : "三级",
							display : "三级"
						}, {
							value : "临时",
							display : "临时"
						}]
						}),
					valueField : "value",
					displayField : "display",
					typeAhead : false,
					mode : "local",
					triggerAction : "all",
					emptyText : "请选择",
					selectOnFocus : true,
					anchor : "100%",
					hidden : false,
					editable : false
				})
				items.push({
					fieldLabel : divo.required+"资质证书编号",
					readOnly : this.readOnly,
					name : "projecter_qualification_number",
					width : 400
				})
			}
			if (this.projecterInputType==2) {
				items.push({
					fieldLabel : divo.required+"施工(消防专业承包)单位",
					readOnly : this.readOnly,
					name : "projecter_name_raw",
					width : 400
				})
			}
		} else {
			//正式使用时
			if (this.projecterInputType==1) {
				items.push(this.projecterFld)
			}
			if (this.projecterInputType==2) {
				items.push({
					fieldLabel : divo.required+"施工(消防专业承包)单位",
					readOnly : this.readOnly,
					name : "projecter_name_raw",
					width : 400
				})
			}
		}	
		items.push({
				fieldLabel : divo.required,
				labelSeparator : "",
				xtype : 'formHtml',
				hidden : this.readOnly,
				value : '为了保证报告打印质量，请使用回车换行。'
		})
		items.push({
				xtype : 'textarea',
				fieldLabel : "系统概述",
				name : "descrip",
				readOnly : this.readOnly,
				grow : true,
				width : 550
		})
		var items2 = [{	
			fieldLabel : "1、正压送风系统参数表",
			text : '添加...',
			xtype : this.readOnly?'formHtml':'formBtn',
			handler : this.showAddWin121,
			scope : this
		},{	
			hideLabel : true,
			xtype : 'formHtml',
			value : '<div id="'+this.myId("h121")+'">'+this.show121()+'</div>'
		}, {
			xtype : 'textarea',
			fieldLabel : "备注:<br/>(1)风口形式<br/>及联动方式",
			name : 'note_01',
			readOnly : this.readOnly,
			width : 580,
			height : 50
		}, {
			xtype : 'textarea',
			fieldLabel : "(2)其他情况<br/>说明",
			name : 'note_02',
			readOnly : this.readOnly,
			width : 580,
			height : 50
		}, {
			fieldLabel : "2、排烟及排烟时的补风系统参数检测结果",
			text : '添加...',
			xtype : this.readOnly?'formHtml':'formBtn',
			handler : this.showAddWin122,
			scope : this
		},{	
			hideLabel : true,
			xtype : 'formHtml',
			value : '<div id="'+this.myId("h122")+'">'+this.show122()+'</div>'
		}, {
			xtype : 'textarea',
			fieldLabel : "备注:<br/>(1)风口形式<br/>及联动方式",
			name : 'note_03',
			readOnly : this.readOnly,
			width : 580,
			height : 50
		}, {
			xtype : 'textarea',
			fieldLabel : "(2)其他情况<br/>说明",
			name : 'note_04',
			readOnly : this.readOnly,
			width : 580,
			height : 50
		}]
		Ext.apply(this, {
			labelWidth : 180,
			defaultType : "textfield",
			labelAlign : "right",
			autoScroll : true,
			bodyStyle : "padding:10px",
			layout : 'autotableform',
			items : items.concat(items2)	
		})
		
		this.subscribe("window.xf.CheckReportResult121Changed",this.onShowHtml,this)
		this.subscribe("window.xf.CheckReportResult122Changed",this.onShowHtml,this)
		this.on('beforedestroy',function() {
		      this.unsubscribe()
		},this)
		
		form.xf.CheckReportHome102Form.superclass.initComponent.call(this)
	},
	//重写
	loadItem : function() {
		Ext.Ajax.request({
			scope : this,
			url : this.url,
			method : 'GET',
			success : function(response, options) {
				var resp = Ext.decode(response.responseText)
				if (resp.success) {
					this.getForm().setValues(resp.data)
					
					var fld = this.getForm().findField("projecter_id")
					if (fld)
						fld.setNameValue(resp.data.projecter_name,resp.data.projecter_id)
				}
			},
			failure : function(response, options) {
				this.alert(response.responseText);
			}
		})
	},
	show121 : function() {
		var partCode = "121"
		var url = "/xf/checkreports/" + this.checkReportId + "/system/"+this.systemId
		var data = this.getResultRecords(partCode,url)
		if (data.length==0)  {
			return ""
		}
		var h = []
		h.push('<table class="divo-table" align="center" border="1" cellpadding="0" cellspacing="0" width="830"><tbody>')
       	h.push('<tr height="20"><td width="18" align="right">序<br/>号</td>')
       	h.push('<td width="120" align="center">系统名称</td>')
       	h.push('<td width="120" align="center">风机编号(位置)</td>')
       	h.push('<td width="120" align="center">保护区域</td>')
       	h.push('<td width="70" align="center">风量<br/>(m3/h)</td>')
       	h.push('<td width="70" align="center">风压<br/>(Pa)</td>')
       	h.push('<td width="70" align="center">功率<br/>(kW)</td>')
       	h.push('<td width="70" align="center">转速<br/>(r/min)</td>')
       	h.push('<td width="70" align="center">数量<br/>(台)</td>')
       	if (this.readOnly)
       		h.push('</tr>')
       	else	
       		h.push('<td width="80" align="center">操作</td></tr>')
        for (var i = 0; i < data.length; i++) {
        	v = data[i]
	       	h.push('<tr height="20"><td width="18" align="right">'+v.order_number+'</td>')
	       	h.push('<td width="120" align="center">'+this.getRecordData(v.name)+'</td>')
	       	h.push('<td width="120" align="center">'+this.getRecordData(v.r1)+'</td>')
	       	h.push('<td width="120" align="center">'+this.getRecordData(v.r2)+'</td>')
	       	h.push('<td width="70" align="center">'+this.getRecordData(v.r3)+'</td>')
	       	h.push('<td width="70" align="center">'+this.getRecordData(v.r4)+'</td>')
	       	h.push('<td width="70" align="center">'+this.getRecordData(v.r5)+'</td>')
	       	h.push('<td width="70" align="center">'+this.getRecordData(v.r6)+'</td>')
	       	h.push('<td width="70" align="center">'+this.getRecordData(v.r7)+'</td>')
	       	if (this.readOnly)
		       	h.push('</tr>')
		    else   	
		       	h.push('<td width="80" align="center">'+this.getResultOperationStr(v.id,partCode)+'</td></tr>')
        }   
        h.push(this.tableEnd)
        return h.join("")   
	},
	showAddWin121 : function() {
		var win = new window.xf.CheckReportResultAddOrEditWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			winTitle : '添加正压送风系统参数表',
			partCode : '121',
			customWidth : 450,
			adding : true
		})
		win.show()
	},
	showEditWin121 : function(id) {
		var win = new window.xf.CheckReportResultAddOrEditWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			winTitle : '修改正压送风系统参数表',
			partCode : '121',
			adding : false,
			customWidth : 450,
			resultRecordId : id
		})
		win.show()
	},
	show122 : function() {
		var partCode = "122"
		    
		var url = "/xf/checkreports/" + this.checkReportId + "/system/"+this.systemId
		var data = this.getResultRecords(partCode,url)
		if (data.length==0)  {
			return ""
		}
		var h = []
		h.push('<table class="divo-table" align="center" border="1" cellpadding="0" cellspacing="0" width="830"><tbody>')
       	h.push('<tr height="20"><td width="18" align="right">序<br/>号</td>')
       	h.push('<td width="120" align="center">系统名称</td>')
       	h.push('<td width="120" align="center">风机编号(位置)</td>')
       	h.push('<td width="120" align="center">保护区域</td>')
       	h.push('<td width="70" align="center">风量<br/>(m3/h)</td>')
       	h.push('<td width="70" align="center">风压<br/>(Pa)</td>')
       	h.push('<td width="70" align="center">功率<br/>(kW)</td>')
       	h.push('<td width="70" align="center">转速<br/>(r/min)</td>')
       	h.push('<td width="70" align="center">数量<br/>(台)</td>')
       	if (this.readOnly)
       		h.push('</tr>')
       	else	
       		h.push('<td width="80" align="center">操作</td></tr>')
        for (var i = 0; i < data.length; i++) {
        	v = data[i]
	       	h.push('<tr height="20"><td width="18" align="right">'+v.order_number+'</td>')
	       	h.push('<td width="120" align="center">'+this.getRecordData(v.name)+'</td>')
	       	h.push('<td width="120" align="center">'+this.getRecordData(v.r1)+'</td>')
	       	h.push('<td width="120" align="center">'+this.getRecordData(v.r2)+'</td>')
	       	h.push('<td width="70" align="center">'+this.getRecordData(v.r3)+'</td>')
	       	h.push('<td width="70" align="center">'+this.getRecordData(v.r4)+'</td>')
	       	h.push('<td width="70" align="center">'+this.getRecordData(v.r5)+'</td>')
	       	h.push('<td width="70" align="center">'+this.getRecordData(v.r6)+'</td>')
	       	h.push('<td width="70" align="center">'+this.getRecordData(v.r7)+'</td>')
	       	if (this.readOnly)
		       	h.push('</tr>')
		    else   	
		       	h.push('<td width="80" align="center">'+this.getResultOperationStr(v.id,partCode)+'</td></tr>')
        }   
        h.push(this.tableEnd)
        return h.join("")   
	},
	showAddWin122 : function() {
		var win = new window.xf.CheckReportResultAddOrEditWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			winTitle : '添加排烟及排烟时的补风系统参数表',
			partCode : '122',
			customWidth : 450,
			adding : true
		})
		win.show()
	},
	showEditWin122 : function(id) {
		var win = new window.xf.CheckReportResultAddOrEditWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			winTitle : '修改排烟及排烟时的补风系统参数表',
			partCode : '122',
			adding : false,
			customWidth : 450,
			resultRecordId : id
		})
		win.show()
	}
	
})

Ext.reg("form.xf.CheckReportHome102Form", form.xf.CheckReportHome102Form)
// EOP

;/**
 * 检测结论添加表单
 */
form.xf.CheckDescripFormPanel = Ext.extend(Ext.form.FormPanel, {
	initFocusFldName : 'code',
	checkReportId : null,
	checkerId : null,
	initComponent : function() {
		Ext.apply(this, {
			labelWidth : 240,
			defaultType : "textfield",
			labelAlign : "right",
			autoScroll : true,
			bodyStyle : "padding:10px",
			items : [{
				xtype : 'radiogroup',
				width : 180,
				fieldLabel : '钢结构防火涂料产品市场准入',
				items: [
                    {boxLabel: '符合要求', name: '01',inputValue: '符合要求', checked: true},
                    {boxLabel: '不符合要求', name: '01',inputValue: '不符合要求'}
                ]
			},{
				xtype : 'radiogroup',
				width : 180,
				fieldLabel : '钢结构防火涂料产品现场留样情况',
				items: [
                    {boxLabel: '符合要求', name: '02',inputValue: '符合要求', checked: true},
                    {boxLabel: '不符合要求', name: '02',inputValue: '不符合要求'}
                ]
			},{
				xtype : 'radiogroup',
				width : 180,
				fieldLabel : '钢结构防火外观质量检查',
				items: [
                    {boxLabel: '合格', name: '03',inputValue: '合格', checked: true},
                    {boxLabel: '不合格', name: '03',inputValue: '不合格'}
                ]
			},{
				xtype : 'radiogroup',
				width : 180,
				fieldLabel : '钢结构防火涂料选型检查',
				items: [
                    {boxLabel: '合格', name: '04',inputValue: '合格', checked: true},
                    {boxLabel: '不合格', name: '04',inputValue: '不合格'}
                ]
			},{
				xtype : 'radiogroup',
				width : 180,
				fieldLabel : '钢结构防火涂料涂层厚度检测',
				items: [
                    {boxLabel: '合格', name: '05',inputValue: '合格', checked: true},
                    {boxLabel: '不合格', name: '05',inputValue: '不合格'}
                ]
			},{
				xtype : 'radiogroup',
				width : 180,
				fieldLabel : '膨胀型钢结构防火涂料膨胀倍数检测',
				items: [
                    {boxLabel: '合格', name: '06',inputValue: '合格', checked: true},
                    {boxLabel: '不合格', name: '06',inputValue: '不合格'}
                ]
			}]
		})

		form.xf.CheckDescripFormPanel.superclass.initComponent.call(this);
	},
	//public
	getContent : function() {
		var content = []
		var val = this.getForm().getObjectValues()
		
		content.push("钢结构防火涂料产品市场准入"+val['01'])
		content.push("钢结构防火涂料产品现场留样情况"+val['02'])
		content.push("钢结构防火外观质量检查"+val['03'])
		content.push("钢结构防火涂料选型检查"+val['04'])
		content.push("钢结构防火涂料涂层厚度检测"+val['05'])
		content.push("膨胀型钢结构防火涂料膨胀倍数检测"+val['06'])
		
		//for(var i=1;i <=6;i++){
			//var fld = this.getForm().findField("0"+i)
			//content.push(fld.fieldLabel+fld.getValue())
		//}
		
		return content.join('\n')
	}
})

Ext.reg("form.xf.CheckDescripFormPanel", form.xf.CheckDescripFormPanel)
// EOP

;/**
 * 喷淋泵组新建
 */
form.xf.CheckReportContent162AddOrEditForm = Ext.extend(divo.form.AddOrEditForm, {
	checkReportId : null,
	systemId : null,
	systemItems : null,
	initComponent : function() {
		this.url = "/xf/checkreports/"+this.checkReportId+"/system/"+
					this.systemId+"/part162"
		Ext.apply(this, {
			labelWidth : 100,
			defaultType : "textfield",
			labelAlign : "right",
			autoScroll : true,
			bodyStyle : "padding:10px",
			items : this.getRecordItems() 
		})
		form.xf.CheckReportResultBaseAddOrEditForm.superclass.initComponent.call(this);
	},
	getRecordItems : function() {
		var items = []
//		items.push({
//				fieldLabel : "小标题",
//				name : "name",
//				width : 100
//		})
		for (var i = 0; i < this.systemItems.length; i++) {
			if (i==0)
				items.push({
					xtype : 'checkbox',
					fieldLabel: '所属小系统',
                	boxLabel: this.systemItems[i].name,
                	name: 'item-'+this.systemItems[i].code				
				})
			else
				items.push({
					xtype : 'checkbox',
                    fieldLabel: '',
                    labelSeparator: '',
                	boxLabel: this.systemItems[i].name,
                	name: 'item-'+this.systemItems[i].code					
				})
		}
		return items
	},
	// public
	save : function(callbackOnSuccess) {
		var item = this.getForm().getObjectValues()
		var itemCodeList = "", itemNameList = ""
		for (var i = 0; i < this.systemItems.length; i++) {
			var f = this.getForm().findField('item-'+this.systemItems[i].code)
			if (f.getValue()) {
				itemCodeList += ","+this.systemItems[i].code
				itemNameList += ","+this.systemItems[i].name
			}
		}
		if (itemCodeList.length==1) {
			this.say("必须选择至少一个小系统")
			return
		}
		item.item_code_list = itemCodeList.substr(1,itemCodeList.length-1)
		item.item_name_list = itemNameList.substr(1,itemNameList.length-1)
		
		Ext.Ajax.request({
			scope : this,
			url : this.url,
			waitMsg : "正在提交...",
			method : 'POST',
			jsonData : item,
			success : function(response, options) {
				var resp = Ext.decode(response.responseText)
				if (!resp.success) {
					this.getForm().markInvalid(resp.errors)
				} else {
					callbackOnSuccess(resp.id)
				}
			},
			failure : function(response, options) {
				this.alert(response.responseText)
			}
		})
	}
})

Ext.reg("form.xf.CheckReportContent162AddOrEditForm", form.xf.CheckReportContent162AddOrEditForm)
// EOP

;/**
 * 检测报告新建或修改窗口
 *
 * --------------------------------------------------------------
 * 消息：
 * 检测报告新增或修改了
 * 
 * 消息名：     			
 * window.xf.CheckReportChanged    
 * 
 * 消息内容：
 * {int} sender 本组件的id值
 * --------------------------------------------------------------
 */
window.xf.CheckReportAddOrEditWindow = Ext.extend(Ext.Window, {
	cancelAction : "hide",  //还可以取值：destroy
	closeAction : "hide",
	adding : false,
	checkReportId : null,
	checkerId : null,
	initComponent : function() {
		Ext.apply(this,{
			title : (this.adding?'新建':'修改')+' 检测报告',
			width : 550,
			height : 250,
			modal : true,
			stateful : true,
			stateId : 'xf-check-report-win',
			closable : true,
			maximizable : false,
			minimizable : false,
			layout : "fit",
			buttons : [{
				text : "确定",
				handler : this.onSave,
				scope : this
			}, {
				text : "取消",
				handler : this.onCancel,
				scope : this
			}],
			items : {
				xtype : "form.xf.CheckReportAddOrEditForm",
				adding : this.adding,
				checkReportId : this.checkReportId,
				checkerId : this.checkerId
			}
		});
		
		window.xf.CheckReportAddOrEditWindow.superclass.initComponent.call(this);
	},
	onSave : function() {
		this.items.itemAt(0).save(this.onSaveSucccess.createDelegate(this))
	},
	onSaveSucccess : function(id) {
	    this.close()
		
		this.publish("window.xf.CheckReportChanged",{
			sender:this.id,
			id : id
		})
	}
})
// EOP

;/**
 * 检测报告验证结果
 */
window.xf.CheckReportValidateResultWindow = Ext.extend(Ext.Window, {
	cancelAction : "hide",  
	closeAction : "hide",
	checkReportId : null,
	checkReportCode : null,
	initComponent : function() {
		Ext.apply(this,{
			title : '检测报告验证结果:No'+this.checkReportCode,
			stateful : true,
			stateId : 'xf-check-reprt-validate-result-win',
			width : 750,
			height : 500,
			modal : false,
			closable : true,
			maximizable : true,
			minimizable : false,
			layout : "fit",
			buttons : [{
				text : "关闭",
				handler : this.onCancel,
				scope : this
			}],
			items : {
				xtype : "panel.xf.CheckReportValidateResultGridPanel",
				checkReportId : this.checkReportId
			}
		})
		
		window.xf.CheckReportValidateResultWindow.superclass.initComponent.call(this);
	}
})
// EOP

;/**
 * 查看检测报告PDF窗口
 */
window.xf.CheckReportPDFWindow = Ext.extend(Ext.Window, {
	cancelAction : "hide",  //还可以取值：destroy
	closeAction : "hide",
	checkReportId : null,
	systemId : null, //0表示总表 null表示打印全部
	reportTitle : null,
	closed : false, //是否打印已完成报告？
	logId : null,
	initComponent : function() {
		if (this.closed) {
			if (this.logId)
				this.url = "/xf/checkreports/"+this.checkReportId+"/logs/"+this.logId+"/pdf"
			else	
				this.url = "/xf/checkreports/"+this.checkReportId+"/latest/pdf"
			this.url += '?auth='+Ext.Ajax.defaultHeaders.Authorization
		} else {	
			this.url = "/xf/checkreports/"+this.checkReportId+"/pdf"
			this.url += '?systemId='+(this.systemId==null?'':this.systemId)+'&auth='+Ext.Ajax.defaultHeaders.Authorization
		}	

		Ext.apply(this,{
			title : '检测报告'+(this.reportTitle?' - '+this.reportTitle:''),
			stateful : true,
			stateId : 'xf-check-report-pdf-win',
			width : 850,
			height : 520,
			modal : true,
			closable : true,
			maximizable : true,
			minimizable : false,
			layout : "fit",
			buttons : [{
				text : "关闭",
				handler : this.onCancel,
				scope : this
			}],
			items : this.createLayoutPanel()
		})
		
		this.subscribe("panel.xf.CheckReportItemBrkLineChanged",this.onLineBrkChanged,this)
		this.on('beforedestroy',function() {
		      this.unsubscribe()
		},this)
		
		window.xf.CheckReportPDFWindow.superclass.initComponent.call(this);
	},
	onLineBrkChanged : function(subj, msg, data) {
		if (msg.sender==this.myId('grid')) {
			Ext.getCmp(this.myId('pdf')).refreshMedia()
		}
	},
	createLayoutPanel : function() {
		var items = []
		items.push({
				region : 'center',
				layout : 'fit',
				autoScroll : true,
				items : [{
					id : this.myId('pdf'),
					xtype : "mediapanel",
					mediaCfg:{
					   mediaType:'PDF',
			           url: this.url,
			           controls:true,
			           start:true
					}
				}]
			})
		if (!this.readOnly && this.systemId) 
			items.push({
				title : '插入换页符',
				region : 'east',
				layout : 'fit',
				stateful : true,
				stateId : this.myId('east'),
				autoScroll : true,
				collapsedTitle : true,
				collapsed : true,
				width : 450,
				split : true,
				items : [{
					id : this.myId('grid'),
					xtype : "panel.xf.CheckReportItemBrkLineGridPanel",
					checkReportId : this.checkReportId,
					systemId : this.systemId,
					readOnly : this.readOnly
				}]
			})
			
		return new Ext.Panel({
			layout : 'tdgi_border',
			defaults : {
				border : false
			},
			border : false,
			items : items
		})
	}
})
// EOP

;/**
 * 检测报告总表输入窗口
 * 
 * -------------------------------------------------------------- 
 * 消息： 检测报告内容有输入
 * 
 * 消息名： window.xf.CheckReportContentChanged
 * 
 * 消息内容： {int} sender 本组件的id值
 * --------------------------------------------------------------
 */
window.xf.CheckReportMasterWindow = Ext.extend(Ext.Window, {
	cancelAction : "hide",  //还可以取值：destroy
	closeAction : "hide",
	checkReportId : null,
	checkReportType : null,
	readOnly : false,
	initComponent : function() {
		this.formId = this.myId('form')
		var btns = [{
				text : "打印预览...",
				handler : this.onPreview,
				scope : this
			},{
				text : "保存并继续",
				handler : this.onSave,
				scope : this
			},{
				text : "保存并关闭",
				handler : this.onCancel,
				scope : this
			}]
		if (this.readOnly)
		   btns = [{
				text : "关闭",
				handler : this.onCancel,
				scope : this
			}] 
			
		Ext.apply(this,{
			title : '检测报告总表: No'+this.checkReportCode,
			stateful : true,
			stateId : 'xf-check-report-master-win',
			width : 750,
			height : 500,
			modal : true,
			closable : true,
			maximizable : true,
			minimizable : false,
			layout : "fit",
			buttons : btns,
			items : {
				xtype : "form.xf.CheckReportMasterForm",
				checkReportId : this.checkReportId,
			    checkReportType : this.checkReportType,
				id : this.formId,
				readOnly : this.readOnly
			}
		})
		window.xf.CheckReportMasterWindow.superclass.initComponent.call(this)
	},
	onCancel : function() {
		if (!this.readOnly)		
			this.onSave()
		
		window.xf.CheckReportMasterWindow.superclass.onCancel.call(this)
	},
	onPreview : function() {
		this.onSave()
		
		var win = new window.xf.CheckReportPDFWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReportId,
			systemId : 0,
			reportTitle : '总表'
		})
		win.show()
	},
	onSave : function() {
		var form = Ext.getCmp(this.formId)
		//if (!form.hasChanged()) return
		
		this.buttons[0].setDisabled(true)
		this.buttons[1].setDisabled(true)
		this.buttons[2].setDisabled(true)
		form.save(true)
		this.say("保存完毕")
		this.buttons[0].setDisabled(false)
		this.buttons[1].setDisabled(false)
		this.buttons[2].setDisabled(false)
		
		this.publish("window.xf.CheckReportContentChanged", {
			sender : this.id
		})
	},
	render : function() {
		window.xf.CheckReportMasterWindow.superclass.render.apply(this, arguments)
		
		new Ext.KeyMap(this.el, [{
			key: Ext.EventObject.S,
			ctrl:true,
			stopEvent: true,
			fn: this.onSave.createDelegate(this)
		}])
	}
	
})
// EOP

;/**
 * 检测依据选择用窗口
 * 
 * --------------------------------------------------------------
 * 消息：
 * 用户选择了检测依据
 * 
 * 消息名：     			
 * window.xf.CheckUnderSelected    
 * 
 * 消息内容：
 * {String} sender 本组件的id值
 * {String} content 所选择的检测依据（回车符换行)
 * --------------------------------------------------------------
 * 
 */
window.xf.CheckUnderWindow = Ext.extend(Ext.Window, {
	cancelAction : "hide",  //还可以取值：destroy
	closeAction : "hide",
	checkReportType : null,
	initComponent : function() {
		Ext.apply(this,{
			title : '可选检测依据',
			stateful : true,
			stateId : 'xf-check-under-win',
			width : 500,
			height : 400,
			modal : true,
			closable : true,
			maximizable : true,
			minimizable : false,
			layout : "fit",
			buttons : [{
				text : "确定",
				handler : this.onSave,
				scope : this
			}, {
				text : "取消",
				handler : this.onCancel,
				scope : this
			}],
			items : {
				id : this.myId('content'),
				xtype : "panel.xf.CheckUnderGridPanel",
				checkReportType : this.checkReportType
			}
		})
		
		window.xf.CheckUnderWindow.superclass.initComponent.call(this);
	},
	onSave : function() {
		var content = Ext.getCmp(this.myId('content')).getContent()
		if (!content) return
		
		this.publish("window.xf.CheckUnderSelected",{
			sender:this.id,
			content:content}
		)
		this.onCancel()
	}
})
// EOP

;/**
 * 检测报告中的设备清单中的产品新建或修改窗口
 *
 * --------------------------------------------------------------
 * 消息：
 * 产品新增或修改了
 * 
 * 消息名：     			
 * window.xf.CheckReportProductChanged    
 * 
 * 消息内容：
 * {int} sender 本组件的id值
 * {int} id 新建记录的Id, 或修改的记录Id
 * --------------------------------------------------------------
 */
window.xf.CheckReportProductAddOrEditWindow = Ext.extend(Ext.Window, {
	cancelAction : "hide",  //还可以取值：destroy
	closeAction : "hide",
	adding : false,
	checkReportId : null,
	productRecordId : null,
	tryOutOnly : null,
	checkReportType : null,
	systemId : null,
	winTitle : null,
	customWidth : null,
	customHeight : null,
	initComponent : function() {
		var btns = [{
				text : "保存并继续",
				handler : this.onSave,
				scope : this
			}, {
				text : "保存并关闭",
				handler : this.onSaveAndClose,
				
				scope : this
			}, {
				text : "关闭",
				handler : this.onCancel,
				scope : this
			}]
		if (!this.adding)
			btns = [{
				text : "保存并关闭",
				handler : this.onSaveAndClose,
				scope : this
			}, {
				text : "关闭",
				handler : this.onCancel,
				scope : this
			}]
		Ext.apply(this,{
			title : this.winTitle,
			width : this.customWidth || 550,
			height : this.customHeight || 250,
			modal : true,
			stateful : true,
			stateId : 'xf-checkreport-product-win',
			closable : true,
			maximizable : true,
			minimizable : false,
			layout : "fit",
			buttons : btns,
			items : {
				xtype : 'form.xf.CheckReportProductAddOrEditForm',
				adding : this.adding,
				productRecordId : this.productRecordId,
				checkReportId : this.checkReportId,
				systemId : this.systemId,
				tryOutOnly : this.tryOutOnly,
				checkReportType : this.checkReportType
			}
		})
		
		window.xf.CheckReportProductAddOrEditWindow.superclass.initComponent.call(this);
	},
	onSave : function() {
		this.items.itemAt(0).save(this.onSaveSucccess.createDelegate(this))
	},
	onSaveSucccess : function(id) {
	    this.items.itemAt(0).clearForm()
		
		this.publish("window.xf.CheckReportProductChanged",{
			sender:this.id,
			id : id
		})
	},
	onSaveAndClose : function() {
		this.items.itemAt(0).save(this.onSaveAndCloseSucccess.createDelegate(this))
	},
	onSaveAndCloseSucccess : function(id) {
	    this.close()
		
		this.publish("window.xf.CheckReportProductChanged",{
			sender:this.id,
			id : id
		})
	}
})
// EOP

;/**
 * 检测报告中所用产品显示窗口
 */
window.xf.CheckReportAllProductWindow = Ext.extend(Ext.Window, {
	cancelAction : "hide",  //还可以取值：destroy
	closeAction : "hide",
	checkReportId : null,
	initComponent : function() {
		Ext.apply(this,{
			title : '工程所用产品清单',
			stateful : true,
			stateId : 'xf-check-reprt-all-product-win',
			width : 750,
			height : 500,
			modal : true,
			closable : true,
			maximizable : true,
			minimizable : false,
			layout : "fit",
			buttons : [{
				text : "关闭",
				handler : this.onCancel,
				scope : this
			}],
			items : {
				xtype : "panel.xf.CheckReportAllProductGridPanel",
				checkReportId : this.checkReportId
			}
		})
		
		window.xf.CheckReportAllProductWindow.superclass.initComponent.call(this);
	}
})
// EOP

;/**
 * 各系统输入窗口
 */
window.xf.CheckReportWindow = Ext.extend(Ext.Window, {
	cancelAction : "hide",  //还可以取值：destroy
	closeAction : "hide",
	checkReportId : null,
	checkReportCode : null,
	checkReport : null,
	readOnly : false,
	sysName : null, 
	systemCode : null,
	systemId : null,
	sysPanelXtype : null,
	customWidth : null,
	customHeight : null,
	initComponent : function() {
		this.checkReportPanelId = this.myId("panel")
		var btns = [{
				text : "打印预览...",
				handler : this.onPreview,
				scope : this
			},{
				text : "保存并继续",
				handler : this.onSave,
				scope : this
			},{
				text : "保存并关闭",
				handler : this.onCancel,
				scope : this
			}]
		if (this.readOnly)
		   btns = [{
				text : "关闭",
				handler : this.onCancel,
				scope : this
			}] 
		Ext.apply(this,{
			title : this.sysName+'检测记录表: No'+this.checkReportCode,
			stateful : true,
			stateId : 'xf-check-report-'+this.systemCode+'-win',
			width : this.customWidth || 750,
			height : this.customHeight || 520,
			modal : true,
			closable : true,
			maximizable : true,
			minimizable : false,
			layout : "fit",
			buttons : btns,
			items : {
				id : this.checkReportPanelId,
				xtype : this.sysPanelXtype,
				checkReportId : this.checkReportId,
				readOnly : this.readOnly,
				systemId : this.systemId,
				checkReport : this.checkReport
			}
		})
		
		window.xf.CheckReportWindow.superclass.initComponent.call(this);
	},
	onCancel : function() {
		if (!this.readOnly)		
			this.onSave()
		window.xf.CheckReportWindow.superclass.onCancel.call(this)
	},
	onPreview : function() {
		this.onSave()
		
		var win = new window.xf.CheckReportPDFWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReportId,
			systemId : this.systemId,
			reportTitle : this.sysName
		})
		win.show()
	},
	onSave : function() {
		var p = Ext.getCmp(this.checkReportPanelId)
		
		this.buttons[0].setDisabled(true)
		this.buttons[1].setDisabled(true)
		this.buttons[2].setDisabled(true)
		p.save()
		this.say("保存完毕")
		this.buttons[0].setDisabled(false)
		this.buttons[1].setDisabled(false)
		this.buttons[2].setDisabled(false)
		
		this.publish("window.xf.CheckReportContentChanged", {
			sender : this.id
		})
	},
	render : function() {
		window.xf.CheckReportWindow.superclass.render.apply(this, arguments)
		
		new Ext.KeyMap(this.el, [{
			key: Ext.EventObject.S,
			ctrl:true,
			stopEvent: true,
			fn: this.onSave.createDelegate(this)
		}])
	}
	
})
// EOP

;/**
 * 检测报告总表 - 被检测的建筑物: 新建或修改窗口
 *
 * --------------------------------------------------------------
 * 消息：
 * 建筑物新增或修改了
 * 
 * 消息名：     			
 * window.xf.CheckReportBuildingChanged    
 * 
 * 消息内容：
 * {int} sender 本组件的id值
 * --------------------------------------------------------------
 */
window.xf.CheckReportBuildingAddOrEditWindow = Ext.extend(Ext.Window, {
	cancelAction : "hide",  //还可以取值：destroy
	closeAction : "hide",
	adding : false,
	checkReportId : null,
	buildingRecordId : null,
	winTitle : null,
	customWidth : null,
	customHeight : null,
	initComponent : function() {
		var btns = [{
				text : "保存并继续",
				handler : this.onSave,
				scope : this
			}, {
				text : "保存并关闭",
				handler : this.onSaveAndClose,
				
				scope : this
			}, {
				text : "关闭",
				handler : this.onCancel,
				scope : this
			}]
		if (!this.adding)
			btns = [{
				text : "保存并关闭",
				handler : this.onSaveAndClose,
				scope : this
			}, {
				text : "关闭",
				handler : this.onCancel,
				scope : this
			}]
		Ext.apply(this,{
			title : this.winTitle,
			width : this.customWidth || 650,
			height : this.customHeight || 250,
			modal : true,
			stateful : true,
			stateId : 'xf-checkreport-buildings-win',
			closable : true,
			maximizable : true,
			minimizable : false,
			layout : "fit",
			buttons : btns,
			items : {
				xtype : 'form.xf.CheckReportBuildingAddOrEditForm',
				adding : this.adding,
				buildingRecordId : this.buildingRecordId,
				checkReportId : this.checkReportId
			}
		})
		
		window.xf.CheckReportBuildingAddOrEditWindow.superclass.initComponent.call(this);
	},
	onSave : function() {
		this.items.itemAt(0).save(this.onSaveSucccess.createDelegate(this))
	},
	onSaveSucccess : function(id) {
	    this.items.itemAt(0).clearForm()
		
		this.publish("window.xf.CheckReportBuildingChanged",{
			sender:this.id,
			id : id
		})
	},
	onSaveAndClose : function() {
		this.items.itemAt(0).save(this.onSaveAndCloseSucccess.createDelegate(this))
	},
	onSaveAndCloseSucccess : function(id) {
	    this.close()
		
		this.publish("window.xf.CheckReportBuildingChanged",{
			sender:this.id,
			id : id
		})
	}
})
// EOP

;/**
 * 检测项目选择用窗口
 * 
 * --------------------------------------------------------------
 * 消息：
 * 检测项目选择了
 * 
 * 消息名：     			
 * window.xf.CheckReportItemVisibilityChanged    
 * 
 * 消息内容：
 * {int} sender 本组件的id值
 * --------------------------------------------------------------
 */
window.xf.CheckReportItemVisibilityWindow = Ext.extend(Ext.Window, {
	cancelAction : "hide",  //还可以取值：destroy
	closeAction : "hide",
	checkReportId : null,
	systemId : null,
	initComponent : function() {
		Ext.apply(this,{
			title : '可选检测项目',
			stateful : true,
			stateId : 'xf-check-reprt-item-vi-win',
			width : 500,
			height : 400,
			modal : true,
			closable : true,
			maximizable : true,
			minimizable : false,
			layout : "fit",
			buttons : [{
				text : "关闭",
				handler : this.onCloseMe,
				scope : this
			}],
			items : this.createLayoutPanel()
		})
		
		window.xf.CheckReportItemVisibilityWindow.superclass.initComponent.call(this);
	},
	onCloseMe : function() {
		this.publish("window.xf.CheckReportItemVisibilityChanged",{
			sender:this.id
		})
		this.onCancel()
	},
	createLayoutPanel : function() {
		var html = [
'<p>&nbsp;</p>',
'<p><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;告知：</b>必须检测的内容不应漏选，请慎重操作。<p>',
		].join('')
		return new Ext.Panel({
			layout : 'tdgi_border',
			defaults : {
				border : false
			},
			border : false,
			items : [{
				region : 'center',
				layout : 'fit',
				autoScroll : true,
				items : [{
					xtype : "panel.xf.CheckReportItemVisibilityGridPanel",
					checkReportId : this.checkReportId,
					systemId : this.systemId
				}]
			},{
				region : 'north',
				layout : 'fit',
				autoScroll : true,
				collapsedTitle : true,
				collapsed : false,
				height : 50,
				split : false,
				items : [{
					xtype : "panel",
					html : html
				}]
			}]
		})
	}
})
// EOP

;/**
 * 检测报告中的系统添加窗口
 *
 * --------------------------------------------------------------
 * 消息：
 * 系统新增了
 * 
 * 消息名：     			
 * window.xf.CheckReportSystemAdded    
 * 
 * 消息内容：
 * {int} sender 本组件的id值
 * --------------------------------------------------------------
 */
window.xf.CheckReportSystemAddWindow = Ext.extend(Ext.Window, {
	cancelAction : "hide",  //还可以取值：destroy
	closeAction : "hide",
	checkReportId : null,
	checkReportType : null,
	customWidth : null,
	customHeight : null,
	initComponent : function() {
		Ext.apply(this,{
			title : "添加新系统",
			width : this.customWidth || 550,
			height : this.customHeight || 250,
			modal : true,
			stateful : true,
			stateId : 'xf-checkreport-sys-add',
			closable : true,
			maximizable : true,
			minimizable : false,
			layout : "fit",
			buttons : [{
				text : "确定",
				handler : this.onSave,
				scope : this
			}, {
				text : "取消",
				handler : this.onCancel,
				scope : this
			}],
			items : {
				xtype : 'form.xf.CheckReportSystemAddForm',
				adding : true,
				checkReportId : this.checkReportId,
				checkReportType : this.checkReportType
			}
		})
		
		window.xf.CheckReportSystemAddWindow.superclass.initComponent.call(this);
	},
	onSave : function() {
		this.items.itemAt(0).save(this.onSaveSucccess.createDelegate(this))
	},
	onSaveSucccess : function(id) {
	    this.close()
		
		this.publish("window.xf.CheckReportSystemAdded",{
			sender:this.id,
			id : id
		})
	}
})
// EOP

;/**
 * 检测报告中的检测结果表记录新建或修改窗口
 *
 * --------------------------------------------------------------
 * 消息：
 * 记录新增或修改了
 * 
 * 消息名：     			
 * window.xf.CheckReportRecord<编号>Changed    
 * 
 * 消息内容：
 * {int} sender 本组件的id值
 * {int} id 新建记录的Id, 或修改的记录Id
 * --------------------------------------------------------------
 */
window.xf.CheckReportResultAddOrEditWindow = Ext.extend(Ext.Window, {
	cancelAction : "hide",  //还可以取值：destroy
	closeAction : "hide",
	adding : false,
	checkReportId : null,
	resultRecordId : null,
	partCode : null,
	systemId : null,
	winTitle : null,
	customWidth : null,
	customHeight : null,
	initComponent : function() {
		var btns = [{
				text : "保存并继续",
				handler : this.onSave,
				scope : this
			}, {
				text : "保存并关闭",
				handler : this.onSaveAndClose,
				
				scope : this
			}, {
				text : "关闭",
				handler : this.onCancel,
				scope : this
			}]
		if (!this.adding)
			btns = [{
				text : "保存并关闭",
				handler : this.onSaveAndClose,
				scope : this
			}, {
				text : "关闭",
				handler : this.onCancel,
				scope : this
			}]
		Ext.apply(this,{
			title : this.winTitle,
			width : this.customWidth || 550,
			height : this.customHeight || 500,
			modal : true,
			stateful : true,
			stateId : 'xf-checkreport-result-win',
			closable : true,
			maximizable : true,
			minimizable : false,
			layout : "fit",
			buttons : btns,
			items : {
				xtype : 'form.xf.CheckReportResult'+this.partCode+'AddOrEditForm',
				adding : this.adding,
				resultRecordId : this.resultRecordId,
				checkReportId : this.checkReportId,
				systemId : this.systemId,
				partCode : this.partCode
			}
		})
		
		window.xf.CheckReportResultAddOrEditWindow.superclass.initComponent.call(this);
	},
	onSave : function() {
		this.items.itemAt(0).save(this.onSaveSucccess.createDelegate(this))
	},
	onSaveSucccess : function(id) {
	    this.items.itemAt(0).clearForm()
		
		this.publish("window.xf.CheckReportResult"+this.partCode+"Changed",{
			sender:this.id,
			id : id,
			partCode : this.partCode
		})
	},
	onSaveAndClose : function() {
		this.items.itemAt(0).save(this.onSaveAndCloseSucccess.createDelegate(this))
	},
	onSaveAndCloseSucccess : function(id) {
	    this.close()
		
		this.publish("window.xf.CheckReportResult"+this.partCode+"Changed",{
			sender:this.id,
			id : id,
			partCode : this.partCode
		})
	}
})
// EOP
;/**
 * 检测结论添加窗口
 * 
 * --------------------------------------------------------------
 * 消息：
 * 用户选择了检测结论
 * 
 * 消息名：     			
 * window.xf.CheckDescripSelected    
 * 
 * 消息内容：
 * {String} sender 本组件的id值
 * {String} content 所选择的检测结论（回车符换行)
 * --------------------------------------------------------------
 * 
 */
window.xf.CheckDescripWindow = Ext.extend(Ext.Window, {
	cancelAction : "hide",  //还可以取值：destroy
	closeAction : "hide",
	initComponent : function() {
		Ext.apply(this,{
			title : '添加检测结论',
			stateful : true,
			stateId : 'xf-check-descrip-win',
			width : 500,
			height : 300,
			modal : true,
			closable : true,
			maximizable : true,
			minimizable : false,
			layout : "fit",
			buttons : [{
				text : "确定",
				handler : this.onSave,
				scope : this
			}, {
				text : "取消",
				handler : this.onCancel,
				scope : this
			}],
			items : {
				id : this.myId('content'),
				xtype : "form.xf.CheckDescripFormPanel"
			}
		})
		
		window.xf.CheckDescripWindow.superclass.initComponent.call(this);
	},
	onSave : function() {
		var content = Ext.getCmp(this.myId('content')).getContent()
		if (!content) return
		
		this.publish("window.xf.CheckDescripSelected",{
			sender:this.id,
			content:content}
		)
		this.onCancel()
	}
})
// EOP

;/**
 * 检测项目选择用窗口
 * 
 * --------------------------------------------------------------
 * 消息：
 * 检测项目选择了
 * 
 * 消息名：     			
 * window.xf.CheckReportContentChanged    
 * 
 * 消息内容：
 * {int} sender 本组件的id值
 * --------------------------------------------------------------
 */
window.xf.CheckReportContentWindow = Ext.extend(Ext.Window, {
	cancelAction : "hide",  //还可以取值：destroy
	closeAction : "hide",
	contentData : null,
	initComponent : function() {
		Ext.apply(this,{
			title : '添加检测内容',
			stateful : true,
			stateId : 'xf-check-reprt-content-vi-win',
			width : 500,
			height : 400,
			modal : true,
			closable : true,
			maximizable : true,
			minimizable : false,
			layout : "fit",
			buttons : [{
				text : "关闭",
				handler : this.onCloseMe,
				scope : this
			}],
			items : [{
				xtype : "panel.xf.CheckReportContentGridPanel",
				contentData : this.contentData
			}]
		})
		
		window.xf.CheckReportContentWindow.superclass.initComponent.call(this);
	},
	onCloseMe : function() {
		this.publish("window.xf.CheckReportContentChanged",{
			sender:this.id
		})
		this.onCancel()
	}
})
// EOP

;/**
 * 喷淋泵组定义用窗口
 * 
 * --------------------------------------------------------------
 * 消息：
 * 喷淋泵组定义了
 * 
 * 消息名：     			
 * window.xf.Content162Changed    
 * 
 * 消息内容：
 * {int} sender 本组件的id值
 * --------------------------------------------------------------
 */
window.xf.CheckReportContent162Window = Ext.extend(Ext.Window, {
	cancelAction : "hide",  //还可以取值：destroy
	closeAction : "hide",
	checkReportId : null,
	systemId : null,
	hasContent : null,
	initComponent : function() {
		Ext.apply(this,{
			title : '添加喷淋泵组',
			stateful : true,
			stateId : 'xf-check-reprt-content-162-win',
			width : 500,
			height : 400,
			modal : true,
			closable : true,
			maximizable : true,
			minimizable : false,
			layout : "fit",
			buttons : [{
				text : "生成检测内容",
				handler : this.onSave,
				scope : this
			},{
				text : "关闭",
				handler : this.onCancel,
				scope : this
			}],
			items : [{
				xtype : "panel.xf.CheckReportContent162GridPanel",
				checkReportId : this.checkReportId,
				systemId : this.systemId,
				hasContent : this.hasContent
			}]
		})
		
		window.xf.CheckReportContent162Window.superclass.initComponent.call(this);
	},
	onSave : function() {
		if (this.hasContent) {
			Ext.MessageBox.confirm('确认', '现有检测内容将被删除，要继续吗？', this.createContent106.createDelegate(this))
		} else {
			this.createContent106("yes")
		}
	},
	createContent106 : function(btn) {
		if (btn !== 'yes')
		    return
		    
   		this.buttons[0].setDisabled(true)

		var ok = true
		Ext.Ajax.request({
			scope : this,
			url : "/xf/checkreports/"+this.checkReportId+"/system/"+this.systemId+"/part162/result",
			async : false,
			method : 'POST',
			jsonData : {nodata:1},
			success : function(response, options) {
				var resp = Ext.decode(response.responseText)
				if (resp.success) {
					this.say('操作成功')
					this.publish("window.xf.Content162Changed",{
						sender:this.id
					})
				}
			},
			failure : function(response, options) {
		   		this.buttons[0].setDisabled(false)
				this.alert(response.responseText)
				ok = false
			}
		})
		if (ok)
			this.close()
	}
})
// EOP

;/**
 * 喷淋泵组新建窗口
 *
 * --------------------------------------------------------------
 * 消息：
 * 喷淋泵组新增了
 * 
 * 消息名：     			
 * window.xf.CheckReportContent162Added   
 * 
 * 消息内容：
 * {int} sender 本组件的id值
 * --------------------------------------------------------------
 */
window.xf.CheckReportContent162AddOrEditWindow = Ext.extend(Ext.Window, {
	cancelAction : "hide",  //还可以取值：destroy
	closeAction : "hide",
	adding : false,  //目前暂时只实现了添加功能
	checkReportId : null,
	systemId : null,
	winTitle : null,
	systemItems : null,
	initComponent : function() {
		var btns = [{
				text : "确定",
				handler : this.onSave,
				scope : this
			}, {
				text : "取消",
				handler : this.onCancel,
				scope : this
			}]
		Ext.apply(this,{
			title : this.winTitle,
			width : this.customWidth || 350,
			height : this.customHeight || 250,
			modal : true,
			stateful : true,
			stateId : 'xf-checkreport-content-162-add-win',
			closable : true,
			maximizable : true,
			minimizable : false,
			layout : "fit",
			buttons : btns,
			items : {
				xtype : 'form.xf.CheckReportContent162AddOrEditForm',
				adding : this.adding,
				checkReportId : this.checkReportId,
				systemId : this.systemId,
				systemItems : this.systemItems
			}
		})
		
		window.xf.CheckReportContent162AddOrEditWindow.superclass.initComponent.call(this);
	},
	onSave : function() {
		this.items.itemAt(0).save(this.onSaveSucccess.createDelegate(this))
	},
	onSaveSucccess : function(id) {
		this.close()
		this.publish("window.xf.CheckReportContent162Added",{
			sender:this.id,
			id : id
		})
	}
})
// EOP

;/**
 * 查询检测报告
 */
divo.xf.querycheckreport.MainPanel = Ext.extend(divo.panel.PanelWithHtmlBtns, {
	initComponent : function() {
		this.checkReportGridPanelId = this.myId('checkreport')
		this.checkReportActionPanelId = this.myId('action')
		this.checkReportLogPanelId = this.myId('log')

		Ext.apply(this, {
			layout : 'tdgi_border',
			defaults : {
				border : false
			},
			border : false,
			items : [{
				region : 'center',
				layout : 'fit',
				autoScroll : true,
				title : '已经完成的检测报告列表',
				ctCls : "j-toolbar-dark",
			    items : [this.getCenterContent()]
             },this.createLayoutPanel() 
			]
		})

		this.subscribe("divo.rowSelect"+this.checkReportGridPanelId, this.onCheckReportChange, this)
		this.on('beforedestroy', function() {
			this.unsubscribe()
		}, this)

		divo.xf.querycheckreport.MainPanel.superclass.initComponent.call(this)
	},
	onCheckReportChange : function(subj, msg, data) {
		 Ext.getCmp(this.checkReportActionPanelId).setCurrentCheckReport(msg)
		 Ext.getCmp(this.checkReportLogPanelId).showList(msg.id)
	},
	getCenterContent : function() {
		return new Ext.Panel({
			layout : 'border',
			defaults : {
				border : false
			},
			border : false,
			items : [{
				region : 'center',
				layout : 'fit',
				autoScroll : true,
				items : [{
					id : this.checkReportGridPanelId,
					xtype : "panel.xf.QueryCheckReportGridPanel",
					menuItemId : this.menuItemId
				}]
			}, this.getHtmlBtnsPanel({
					'print' : {
						image : 'checkreport-print.png',
						fn : this.printCheckReport
					},
					'modify' : {
						image : 'checkreport-apply.png',
						fn :this.modifyCheckReport,
						hidden : !this.isCheckerUser()
					},
					'agreeModify' : {
						image : 'checkreport-apply-agree.png',
					    fn :this.agreeModifyCheckReport,
					    hidden: !divo.hasPermission("CheckReportAgree")
					}
				})]
		})
	},
	createLayoutPanel : function() {
		return new Ext.TabPanel({
			stateful : true,
			stateId : this.myId('action'),
			region : 'east',
			collapsible : false,
			split : true,
	        activeTab: 0,
	        width:450,
	        defaults:{autoScroll: true},
	        items:[{
	                title: '检测报告内容',
					id : this.checkReportActionPanelId,
					xtype : "panel.xf.CheckReportActionPanel",
					readOnly : true
	            },{
	                title: '操作日志',
					id : this.checkReportLogPanelId,
					xtype : "panel.xf.CheckReportLogGridPanel"
	            }
	        ]
	    })		
	},
	printCheckReport : function() {
		Ext.getCmp(this.checkReportGridPanelId).printReport()
	},
	modifyCheckReport : function() {
		Ext.getCmp(this.checkReportGridPanelId).showApplication()
	},
	agreeModifyCheckReport : function() {
		Ext.getCmp(this.checkReportGridPanelId).showApplicationAgree()
	}
})

divo.xf.querycheckreport.Main = function() {
	/* ----------------------- private变量 ----------------------- */

	/* ----------------------- private方法 ----------------------- */
	// 创建布局
	function createLayout(parentPanel, menuItemId) {
		parentPanel.add(new divo.xf.querycheckreport.MainPanel({
			id : 'xf-querycheckreport',
			menuItemId : menuItemId
		}))
		parentPanel.doLayout()
	}

	/* ----------------------- public方法 ----------------------- */
	return {

		// 初始化
		init : function(parentPanel, menuItemId) {
			createLayout(parentPanel, menuItemId)
		}

	} // return

}()
// EOP

;/**
 * 检测报告查询结果
 */
panel.xf.QueryCheckReportGridPanel = Ext.extend(divo.panel.SmartGridPanel, {
	initComponent : function() {
		this.corpInfo = this.getCorpInfo()
		this.checkerId  = 0
		if (this.isCheckerUser()) {
			this.checkerId  = this.getCorpInfo().id
		}
		
		Ext.apply(this, {
			url : "/xf/checkreports/queryresult",
			fieldDefinitions : this.getListDefinitions(),
			gridConfig : {
				filter : true,
				gridIdOfView : 'xf-query-checkreports-grid',
				displayLoadMask : false,
				footerSimple : true
			},
			autoScroll : true
		})

		panel.xf.QueryCheckReportGridPanel.superclass.initComponent.apply(this,
				arguments)
	},
	getListDefinitions : function() {
		return [{
			name : 'id'
		},{
			name : 'report_type'
		},{
			name : 'tryout_only'
		}, {
			header: "序号", 
			width: 30, 
			renderer: this.rowNumberRender.createDelegate(this)			
		}, {
			name : 'code',
			header : '报告文号',
			type : 'string',
			searchable : true
		}, {
			name : 'project_name',
			header : '工程名称',
			searchable : true,
			type : 'string',
			renderer: this.wordWrapRender.createDelegate(this)
		}, {
			name : 'check_by',
			header:	'现场检测负责人'
		}, {
			name : 'audit_by',
			header:	'审核人'
		}, {
			name : 'report_date',
			header : '签发日期',
			type : 'string'
		}]
	},
	rowNumberRender : function(value, p, record) {
		var ds = record.store
		var i = ds.lastOptions.params.start
		if (isNaN(i)) {
			i = 0;
		}
		return ds.indexOf(record)+i+1
	},
	printReport : function() {
		if (!this.cId) {
			this.say("请先选择一份检测报告")
			return
		}
		var win = new window.xf.CheckReportPDFWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.cId,
			closed : true
		})
		win.show()
	},
	showApplication : function() {
		if (!this.cId) {
			this.say("请先选择一份检测报告")
			return
		}
		var record = this.selModel.getSelections()[0]
		var win = new window.xf.CheckReportApplicationWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.cId,
			checkReportCode : record.data.code
		})
		win.show()
	},
	showApplicationAgree : function() {
		var win = new window.xf.CheckReportApplicationAgreeWindow({
			closeAction : "destroy",
			cancelAction : "destroy"
		})
		win.show()
	},
	//重写
	onBeforeLoad : function(store, options) {
		store.baseParams.checkerId  = this.checkerId 
	},
	render : function() {
		panel.xf.QueryCheckReportGridPanel.superclass.render.apply(this, arguments)
		this.loadList()
	}
})

Ext.reg('panel.xf.QueryCheckReportGridPanel',panel.xf.QueryCheckReportGridPanel)
//EOP
;/**
 * 检测报告修改申请显示窗口
 */
window.xf.CheckReportApplicationWindow = Ext.extend(Ext.Window, {
	cancelAction : "hide",  
	closeAction : "hide",
	checkReportId : null,
	checkReportCode : null,
	initComponent : function() {
		Ext.apply(this,{
			title : '检测报告修改申请:No'+this.checkReportCode,
			stateful : true,
			stateId : 'xf-check-reprt-application-win',
			width : 750,
			height : 500,
			modal : false,
			closable : true,
			maximizable : true,
			minimizable : false,
			layout : "fit",
			buttons : [{
				text : "关闭",
				handler : this.onCancel,
				scope : this
			}],
			items : {
				xtype : "panel.xf.CheckReportApplicationGridPanel",
				checkReportId : this.checkReportId
			}
		})
		
		window.xf.CheckReportApplicationWindow.superclass.initComponent.call(this);
	}
})
// EOP

;/**
 * 检测报告修改申请受理显示窗口
 */
window.xf.CheckReportApplicationAgreeWindow = Ext.extend(Ext.Window, {
	cancelAction : "hide",  
	closeAction : "hide",
	initComponent : function() {
		Ext.apply(this,{
			title : '检测报告修改申请受理',
			stateful : true,
			stateId : 'xf-check-reprt-application-agree-win',
			width : 750,
			height : 500,
			modal : false,
			closable : true,
			maximizable : true,
			minimizable : false,
			layout : "fit",
			buttons : [{
				text : "关闭",
				handler : this.onCancel,
				scope : this
			}],
			items : {
				xtype : "panel.xf.CheckReportApplicationAgreeGridPanel"
			}
		})
		
		window.xf.CheckReportApplicationAgreeWindow.superclass.initComponent.call(this);
	}
})
// EOP

;/**
 * 检测报告修改申请新建或修改窗口
 * --------------------------------------------------------------
 * 消息：
 * 检测报告修改申请新增或修改了
 * 
 * 消息名：     			
 * window.xf.CheckReportApplicationChanged    
 * 
 * 消息内容：
 * {int} sender 本组件的id值
 * {int} id 新建或修改的记录id值
 * --------------------------------------------------------------
 */
window.xf.CheckReportApplicationAddOrEditWindow = Ext.extend(Ext.Window, {
	cancelAction : "hide",  //还可以取值：destroy
	closeAction : "hide",
	adding : false,
	checkReportId : null,
	checkReportApplicationId : null,
	initComponent : function() {
		var btns = [{
				text : "确定",
				handler : this.onSave,
				scope : this
			}, {
				text : "取消",
				handler : this.onCancel,
				scope : this
			}]
		Ext.apply(this,{
			title : (this.adding?'新建':'修改')+'检测报告修改申请',
			width : 580,
			height : 520,
			modal : true,
			stateful : true,
			stateId : 'xf-check-report-application-add-win',
			closable : true,
			maximizable : false,
			minimizable : false,
			layout : "fit",
			buttons : btns,
			items : {
				xtype : "form.xf.CheckReportApplicationAddOrEditForm",
				adding : this.adding,
				checkReportId : this.checkReportId,
				checkReportApplicationId : this.checkReportApplicationId
			}
		})
		
		window.xf.CheckReportApplicationAddOrEditWindow.superclass.initComponent.call(this);
	},
	onSave : function() {
		this.items.itemAt(0).save(this.onSaveSucccess.createDelegate(this))
	},
	onSaveSucccess : function(id) {
		this.say('新建成功')
		this.close()
		
		this.publish("window.xf.CheckReportApplicationChanged",{
			sender:this.id,
			id : id
		})
	}
	
});
// EOP

;/**
 * 检测报告修改申请新建或修改表单
 */
form.xf.CheckReportApplicationAddOrEditForm = Ext.extend(divo.form.AddOrEditForm, {
	initFocusFldName : 'descrip',
    checkReportId : null,
    checkReportApplicationId : null,
	initComponent : function() {
		var lovDisplay = [divo.t1 + '{name}' + divo.t2].join('')
		
		Ext.apply(this, {
			labelWidth : 100,
			defaultType : "textfield",
			labelAlign : "right",
			autoScroll : true,
			bodyStyle : "padding:10px",
			items : [{
				xtype : 'textarea',
				fieldLabel : "申请修改内容",
				name : "descrip",
				width : 400,
				grow : true,
				growMin: 400
			}]
		})

		form.xf.CheckReportApplicationAddOrEditForm.superclass.initComponent.call(this);
	},
	//重写
    loadItem : function() {
		Ext.Ajax.request({
			scope : this,
			url : "/xf/checkreports/"+this.checkReportId+"/application/"+this.checkReportApplicationId,
			method : 'GET',
			success : function(response, options) {
				var resp = Ext.decode(response.responseText);
				this.getForm().setValues(resp.data)
				
			},
			failure : function(response, options) {
				this.alert(response.responseText);
			}
		})
    },
	// public
	save : function(callbackOnSuccess) {
		var item = this.getForm().getObjectValues()
		item.apply_by = this.getUserFullName()
		item.apply_by_id = this.getUserId()
		item.check_report_id = this.checkReportId
		
		Ext.Ajax.request({
			scope : this,
			url : "/xf/checkreports/"+this.checkReportId+"/application"+(this.adding?"":"/"+this.checkReportApplicationId),
			waitMsg : "正在提交...",
			method : (this.adding?'POST':'PUT'),
			jsonData : item,
			success : function(response, options) {
				var resp = Ext.decode(response.responseText);
				if (!resp.success) {
					this.getForm().markInvalid(resp.errors)
				} else {
					callbackOnSuccess(resp.id)
				}
			},
			failure : function(response, options) {
				this.alert(response.responseText)	
			}
		})
	}
})

Ext.reg("form.xf.CheckReportApplicationAddOrEditForm", form.xf.CheckReportApplicationAddOrEditForm)
// EOP

;/**
 * 检测报告修改申请网格面板
 */
panel.xf.CheckReportApplicationGridPanel = Ext.extend(divo.panel.SmartGridDetailPanel, {
	checkReportId : null,
	initComponent : function() {
		this.action = new Ext.ux.grid.RowActions({
			header : '操作',
			autoWidth : false,
			width : 60,
			actions : [{
				iconCls : 'icon-update',
				tooltip : '修改申请内容',
				hideIndex : 'is_modifying'
			}, {
				iconCls : 'icon-delete',
				tooltip : '删除此申请',
				hideIndex : 'is_modifying'
			}]
		})
		this.action.on('action', this.onAction, this)
		
		Ext.apply(this, {
			fieldDefinitions : this.getListDefinitions(),
			url : '/xf/checkreports/'+this.checkReportId+'/application',
			gridConfig : {
				gridIdOfView : 'xf-check-report-application-grid',
				toolbar : this.createToolbarBtn(),
				plugins : [this.action],
				footerSimple : true,
				displayLoadMask : true
			},
			autoScroll : true
		})
		
		this.subscribe("window.xf.CheckReportApplicationChanged", this.onCheckReportApplicationChanged, this)
		this.on('beforedestroy', function() {
			this.unsubscribe()
		}, this)
		
		panel.xf.CheckReportApplicationGridPanel.superclass.initComponent.apply(this,arguments)
	},
	onAction : function(grid, record, action, row, col) {
		if (action == 'icon-update')
			this.editItem()
		if (action == 'icon-delete')
			this.deleteItem()
	},
	// 重写
	createGridMeta : function() {
		return this.getGridMeta(this.fieldDefinitions,this.isLookup?null:[this.action])
	},
	getListDefinitions : function() {
		return [{
			name : 'id'
		},{
			name : 'descrip',
			header : '申请修改内容',
			type : 'string',
			renderer : this.wordWrapRender.createDelegate(this)
		},{
			name : 'apply_by',
			header : '申请人',
			type : 'string'
		},{
			name : 'added_on',
			header : '提交时间',
			type : 'string'
		},{
			name : 'status_name',
			header : '状态',
			type : 'string'
		},{
			name : 'is_modifying',
			type : 'bool',
			convert : function(v, rec) {
				return rec.status == 1
			}
		}]
	},
	onCheckReportApplicationChanged : function(subj, msg, data) {
		if (msg.sender == this.checkReportApplicationWindowId) {
			this.cIdFocus = msg.id
			this.loadList()
		}
	},
	createToolbarBtn : function() {
		var tb = [];

		var addBtn = new Ext.Toolbar.Button({
			text : '新建',
			tooltip : '新建检测报告修改申请',
			icon : divo.iconAdd,
			cls : 'x-btn-text-icon',
			handler : this.addItem.createDelegate(this)
		})
		tb.push(addBtn)
		return tb
	},
	addItem : function() {
		this.checkReportApplicationWindowId = this.myId('win')
		var win = new window.xf.CheckReportApplicationAddOrEditWindow({
			id : this.checkReportApplicationWindowId,
			closeAction : "destroy",
			cancelAction : "destroy",
			adding : true,
			checkReportId : this.checkReportId
		})
		win.show()
	},
	editItem : function() {
		if (!this.cId) {
			this.say("请先选择要修改的记录")
			return
		}
		this.checkReportApplicationWindowId = this.myId('win')

		var win = new window.xf.CheckReportApplicationAddOrEditWindow({
			id : this.checkReportApplicationWindowId,
			closeAction : "destroy",
			cancelAction : "destroy",
			adding : false,
			checkReportId : this.checkReportId,
			checkReportApplicationId : this.cId
		})
		win.show()
	},
	onDeleteItem : function(id) {
		Ext.Ajax.request({
			scope : this,
			url : '/xf/checkreports/'+this.checkReportId+'/application/'+id,
			method : 'DELETE',
			success : function(response, options) {
				var resp = Ext.decode(response.responseText)
				if (resp.success)
					this.deleteItemCallback()
				else
					this.say(resp.errors.reason)
			},
			failure : function(response, options) {
				this.alert(response.responseText)
			}
		})
	}
})

Ext.reg('panel.xf.CheckReportApplicationGridPanel', panel.xf.CheckReportApplicationGridPanel);
// EOP

;/**
 * 检测报告修改申请网格面板
 */
panel.xf.CheckReportApplicationAgreeGridPanel = Ext.extend(divo.panel.SmartGridDetailPanel, {

	initComponent : function() {
		
		Ext.apply(this, {
			fieldDefinitions : this.getListDefinitions(),
			url : '/xf/checkreports/application/new',
			gridConfig : {
				gridIdOfView : 'xf-check-report-application-agree-grid',
				toolbar : this.createToolbarBtn(),
				footerSimple : true,
				displayLoadMask : true,
				allowGridState : false
			},
			autoScroll : true
		})
		
		this.subscribe("window.xf.CheckReportApplicationChanged", this.onCheckReportApplicationChanged, this)
		this.on('beforedestroy', function() {
			this.unsubscribe()
		}, this)
		
		panel.xf.CheckReportApplicationAgreeGridPanel.superclass.initComponent.apply(this,arguments)
	},
	// 重写
	createGridMeta : function() {
		return this.getGridMeta(this.fieldDefinitions)
	},
	getListDefinitions : function() {
		return [{
			name : 'id'
		},{
			name : 'checker_name',
			header : '公司名称',
			width: 120, 
			type : 'string'
		},{
			name : 'apply_by',
			header : '申请人',
			width: 70, 
			type : 'string'
		},{
			name : 'check_report_code',
			header : '报告文号',
			width: 140, 
			type : 'string'
		},{
			name : 'descrip',
			header : '申请修改内容',
			width: 270, 
			type : 'string',
			renderer : this.wordWrapRender.createDelegate(this)
		},{
			name : 'added_on',
			header : '提交时间',
			width: 130, 
			type : 'string'
		},{
			name : 'is_modifying',
			type : 'bool',
			convert : function(v, rec) {
				return rec.status == 1
			}
		}]
	},
	onCheckReportApplicationChanged : function(subj, msg, data) {
		if (msg.sender == this.checkReportApplicationWindowId) {
			this.cIdFocus = msg.id
			this.loadList()
		}
	},
	createToolbarBtn : function() {
		var tb = [];

		var addBtn = new Ext.Toolbar.Button({
			text : '同意',
			tooltip : '同意检测报告修改申请',
			icon : divo.iconPublish,
			cls : 'x-btn-text-icon',
			handler : this.agreeItem.createDelegate(this)
		})
		tb.push(addBtn)
		return tb
	},
	agreeItem : function() {
		if (!this.cId) {
			this.say("请先选择一个检测报告修改申请")
			return
		}
		Ext.MessageBox.confirm("确认", "确定要同意该修改申请吗？", 
								this.agreeItemConfirm.createDelegate(this))
	},
	agreeItemConfirm : function(btn) {
		if (btn != "yes") {
			return
		}
		Ext.Ajax.request({
			scope : this,
			method : 'PUT',
			url : '/xf/checkreports/application/' + this.cId + '/status/agree',
			success : function(response, options) {
				var resp = Ext.decode(response.responseText)
				if (resp.success)
					this.loadList()
				else
					this.say(resp.errors.reason)
			},
			failure : function(response, options) {
				this.alert(response.responseText) 
			}
		})
	}

})

Ext.reg('panel.xf.CheckReportApplicationAgreeGridPanel', panel.xf.CheckReportApplicationAgreeGridPanel);
// EOP

;/**
 * 操作日志显示网格面板
 */
panel.xf.CheckReportLogGridPanel = Ext.extend(divo.panel.SmartGridPanel, {
	actionCode : null,
	initComponent : function() {
		Ext.apply(this, {
			fieldDefinitions : this.getListDefinitions(),
			gridConfig : {
				gridIdOfView : 'xf-check-report-log-grid',
				displayLoadMask : false,
				footer : false,
				filter : false,
				toolbar : this.createToolbarBtn(),
				allowGridState : false
			},
			autoScroll : true
		})
		
		panel.xf.CheckReportLogGridPanel.superclass.initComponent.apply(this,arguments)
	},
	getListDefinitions : function() {
		return [{
			name : 'id'
		},{
			header: "序号", 
			width: 40, 
			sortable : false,
			renderer: this.rowNumberRender.createDelegate(this)			
		},{
			name : 'descrip',
			header : '描述',
			type : 'string',
			width: 150, 
			sortable : false
		},{
			name : 'user_name',
			header : '操作者',
			width: 100, 
			sortable : false,
			type : 'string'
		},{
			name : 'added_on',
			header : '操作时间',
			width: 150, 
			sortable : false,
			type : 'string'
		}]
	},
	createToolbarBtn : function(){
		var tb = [];

		var printReportBtn = new Ext.Toolbar.Button( {
			text : '打印预览',
			icon : divo.iconUrl + "printer.gif",
			cls : 'x-btn-text-icon',
			handler : this.printReport.createDelegate(this)
		})
		tb.push('->')
		tb.push(printReportBtn)
		return tb
	},
	printReport : function() {
		if (!this.cId) {
			this.say("请先选择日志记录")
			return
		}
		var win = new window.xf.CheckReportPDFWindow({
			closeAction : "destroy",
			cancelAction : "destroy",
			checkReportId : this.checkReportId,
			closed : true,
			logId : this.cId
		})
		win.show()
	},
	//public
	showList : function(id) {
	   if (id)
	   	   this.checkReportId = id
	   
	   if (!this.checkReportId) return
	   
	   this.url = "/xf/checkreports/"+this.checkReportId+"/logs"
	   this.setUrl(this.url)
  	   this.loadList()
	}
})

Ext.reg('panel.xf.CheckReportLogGridPanel', panel.xf.CheckReportLogGridPanel);
// EOP

;